【问题标题】:jQuery UI dialog not appearing Squarespace adblock detectjQuery UI 对话框没有出现 Squarespace adblock 检测
【发布时间】:2016-02-16 02:03:53
【问题描述】:

我创建了一个 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 函数未定义。我不知道为什么。这是我添加的links 和scripts。

<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。谢谢。感谢您的帮助。

【问题讨论】:

    标签: javascript jquery html jquery-ui jquery-ui-dialog


    【解决方案1】:

    问题可能是因为您添加了两次 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 准备好之后您的代码运行

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-03-19
      • 2013-12-17
      • 1970-01-01
      • 1970-01-01
      • 2013-03-26
      • 1970-01-01
      相关资源
      最近更新 更多