Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/431.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Jquery弹出式插件在单击任意位置时关闭_Javascript_Jquery_Jquery Plugins_Magnific Popup - Fatal编程技术网

Javascript Jquery弹出式插件在单击任意位置时关闭

Javascript Jquery弹出式插件在单击任意位置时关闭,javascript,jquery,jquery-plugins,magnific-popup,Javascript,Jquery,Jquery Plugins,Magnific Popup,当我点击弹出窗口的任何地方时,它会关闭,但它不应该这样做,它应该只在我点击X按钮时关闭。我使用放大弹出插件。作者的演示很好,但是当我在我的站点上实现插件时,它的工作方式与演示不一样。这给我带来了问题,因为如果我尝试单击弹出窗口中的任何链接,它会关闭弹出窗口而不是打开链接 知道是什么原因吗?代码如下: <script type="text/javascript"> $(document).ready(function() { $('.simple-ajax

当我点击弹出窗口的任何地方时,它会关闭,但它不应该这样做,它应该只在我点击X按钮时关闭。我使用放大弹出插件。作者的演示很好,但是当我在我的站点上实现插件时,它的工作方式与演示不一样。这给我带来了问题,因为如果我尝试单击弹出窗口中的任何链接,它会关闭弹出窗口而不是打开链接

知道是什么原因吗?代码如下:

<script type="text/javascript">
      $(document).ready(function() {

        $('.simple-ajax-popup-align-top').magnificPopup({
          type: 'ajax',
          alignTop: true,
          overflowY: 'scroll' // as we know that popup content is tall we set scroll overflow by default to avoid jump
        });

        $('.simple-ajax-popup').magnificPopup({
          type: 'ajax'
        });

      });
    </script>

<a class="simple-ajax-popup-align-top ajax-gal"  href="test.html">test</a>

作者的演示站点:

有几个选项可以控制关闭行为

closeOnContentClick: false, // if true, closes the popup if you click on it
closeOnBgClick: true, // if true, closes the popup if you click on the grey stuff around it
showCloseBtn: false, //if true, shows a closing button top right.
您可以在此处了解有关这些选项的更多信息:

因为您是一个懒惰的程序员:

<script type="text/javascript">
  $(document).ready(function() {

    $('.simple-ajax-popup-align-top').magnificPopup({
      type: 'ajax',
      alignTop: true,
      closeOnContentClick: false,
      closeOnBgClick: true,
      showCloseBtn: false,
      overflowY: 'scroll' // as we know that popup content is tall we set scroll overflow by default to avoid jump
    });

    $('.simple-ajax-popup').magnificPopup({
      type: 'ajax',
      closeOnContentClick: false,
      closeOnBgClick: true,
      showCloseBtn: false
    });

  });
</script>

jsfiddle或至少是加载到lightbox中的内容看起来有一个名为closeOnContentClick的选项,默认情况下应该为false,但它描述了您看到的行为。可能会尝试显式地将其设置为false?检查弹出窗口创建的元素的zindex,看看是否有任何元素分层在它们的顶部z轴上,可能会干扰单击事件。我刚刚添加了jsfiddle,但我不确定如何在本地添加ajax-test.html,以便在框中加载,现在它不能在ajax中加载文件,因为它不能加载远程文件