简体   繁体   English

jQuery UI对话框未出现Squarespace adblock检测

[英]jQuery UI dialog not appearing Squarespace adblock detect

I have created an AdBlock detector, and my jQuery dialog does not seem to be working. 我创建了一个AdBlock检测器,但我的jQuery对话框似乎无法正常工作。 Note: the "adblock" variable is already referenced. 注意:“ adblock”变量已被引用。 Also, I am using Squarespace, which is why I had to add the code to the body. 另外,我正在使用Squarespace,这就是为什么我必须将代码添加到主体的原因。

if(adblock) { 
    $("body").html('<div id="alert-dialog" title="Turn off AdBlock"> Please turn your AdBlocker off. It hurts our business. To turn off AdBlock, just disable it on this page. Thank you.<br><br><br> Sincerely, The <i>Wildwood Howl</i></div>'+$("body").html()); 
    $(function() { 
        $( "#alert-dialog" ).dialog(); 
    }); 
} 

Here is the error: 这是错误:

TypeError: $("#alert-dialog").dialog is not a function

AKA the dialog function is undefined. dialog功能也未定义。 I don't know why. 我不知道为什么 Here are my added links and scripts . 这是我添加的linksscripts

<link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<script src="https://code.jquery.com/jquery-latest.min.js"></script>

Click here to see my page. 点击这里查看我的页面。 Also, there are supposed to be background images, but they are not showing up. 另外,应该有背景图片,但是没有显示出来。

I can provide a jsfiddle for this. 我可以为此提供一个jsfiddle。 Thanks. 谢谢。 Help is appreciated. 感谢帮助。

The problem is probably because you're adding jQuery twice. 问题可能是因为您要添加jQuery两次。

<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<script src="https://code.jquery.com/jquery-latest.min.js"></script>
---------------^ remove this

jQuery UI extends the $ created by jquery-1.10.2 , but then you add jquery-latest.min.js which probably overwrites the $ created earlier which has the jQuery UI functions. jQuery UI扩展了由jquery-1.10.2创建的$ ,但随后添加jquery-latest.min.js ,这可能会覆盖先前创建的具有jQuery UI功能的$

also make sure you're code runs after these two scripts are evaluated and DOM is ready 还请确保在评估了这两个脚本并且DOM准备就绪后您正在运行代码

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM