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

jQuery UI dialog not appearing Squarespace adblock detect

我创建了 AdBlock 检测器,但我的 jQuery 对话框似乎无法正常工作。注意:"adblock" 变量已被引用。此外,我正在使用 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(); 
    }); 
} 

这是错误:

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

又名 dialog 函数未定义。我不知道为什么。这是我添加的 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>

点击here查看我的页面。另外,应该有背景图,但是没有显示。

我可以为此提供一个 jsfiddle。谢谢。感谢帮助。

问题可能是因为您添加了两次 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 扩展了 jquery-1.10.2 创建的 $,但是你添加了 jquery-latest.min.js,这可能会覆盖之前创建的 $它具有 jQuery UI 功能。

还要确保您的代码在评估这两个脚本并且DOM 准备就绪后运行