<i id='8kfi8'><tr id='8kfi8'><dt id='8kfi8'><q id='8kfi8'><span id='8kfi8'><b id='8kfi8'><form id='8kfi8'><ins id='8kfi8'></ins><ul id='8kfi8'></ul><sub id='8kfi8'></sub></form><legend id='8kfi8'></legend><bdo id='8kfi8'><pre id='8kfi8'><center id='8kfi8'></center></pre></bdo></b><th id='8kfi8'></th></span></q></dt></tr></i><div id='8kfi8'><tfoot id='8kfi8'></tfoot><dl id='8kfi8'><fieldset id='8kfi8'></fieldset></dl></div>
      1. <tfoot id='8kfi8'></tfoot>

        <small id='8kfi8'></small><noframes id='8kfi8'>

      2. <legend id='8kfi8'><style id='8kfi8'><dir id='8kfi8'><q id='8kfi8'></q></dir></style></legend>
        • <bdo id='8kfi8'></bdo><ul id='8kfi8'></ul>

        如何防止谷歌浏览器阻止我的弹出窗口?

        时间:2023-10-01
          • <i id='6uTbs'><tr id='6uTbs'><dt id='6uTbs'><q id='6uTbs'><span id='6uTbs'><b id='6uTbs'><form id='6uTbs'><ins id='6uTbs'></ins><ul id='6uTbs'></ul><sub id='6uTbs'></sub></form><legend id='6uTbs'></legend><bdo id='6uTbs'><pre id='6uTbs'><center id='6uTbs'></center></pre></bdo></b><th id='6uTbs'></th></span></q></dt></tr></i><div id='6uTbs'><tfoot id='6uTbs'></tfoot><dl id='6uTbs'><fieldset id='6uTbs'></fieldset></dl></div>

            1. <small id='6uTbs'></small><noframes id='6uTbs'>

                <bdo id='6uTbs'></bdo><ul id='6uTbs'></ul>
                <tfoot id='6uTbs'></tfoot>

                  <legend id='6uTbs'><style id='6uTbs'><dir id='6uTbs'><q id='6uTbs'></q></dir></style></legend>

                    <tbody id='6uTbs'></tbody>
                1. 本文介绍了如何防止谷歌浏览器阻止我的弹出窗口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  在我的网站上,有一个按钮仅用于调用调用 window.open 的函数,但是,最近需要进行调整以在打开弹出窗口之前进行服务器端检查.

                  On my website there is a button that just used to call a function that calls window.open, however, recently an adjustment was needed to do a server-side check before the popup was opened.

                  自从添加了执行 AJAX 调用的代码后,浏览器就会阻止在 AJAX 调用的 success 回调中打开的弹出窗口.我读到如果用户点击事件没有调用浏览器可能会阻止弹出窗口,所以我尝试将 AJAX 请求设置为 async: false,这解决了 Firefox 中的问题,但谷歌浏览器仍然阻止我的弹出窗口.有没有办法解决这个问题?

                  Ever since the code was added that does the AJAX call, browsers blocks the popup, that is opened in the success callback of the AJAX call. I read that browsers might block the popup if it's not called by a user click event, so I tried setting the AJAX request to async: false, which solved the problem in Firefox, but Google Chrome still keeps blocking my popup. Is there any way to get around this?

                  我可以将服务器端检查移至在弹出窗口中打开的页面,但如果可能的话,我想在打开弹出窗口之前执行此操作.

                  I could move the server-side check to the page that gets opened in the popup, but I'd like to do it before opening the popup, if possible.

                  代码:

                  <a id="attackButton" href="#">Attack Base!</a>
                  
                  <script type="text/javascript">
                  $(function() {
                      $('#attackButton').click(function() {
                          $.ajax({
                              url: baseurl + '/index.php?option=com_pbbgs&format=raw&getinfo=goingame',
                              data: { 'gameid': 618 },
                              dataType: 'text',
                              async: false,
                              type: 'POST',
                              success: function(data) {
                                  eval(data);
                  
                                  if (window.gameURL) {
                                      goingameRaw();
                                  }
                              }
                          });
                  
                          return false;
                      });
                  });
                  
                  function goingameRaw()
                  {
                      window.open(window.gameURL,'test','left=20,top=20,width=1024,height=640,toolbar=0,resizable=0,location=0');
                  }
                  </script>
                  

                  示例响应正文:

                  window.gameURL="http://mydomain.com/index.php?option=com_pbbgs&format=raw&startgame=618&width=1024&height=640";checktutorial('js','attack');
                  

                  推荐答案

                  是的,弹出窗口应该是用户操作的直接结果.在 ajax 回调中执行它们不会成功.此外,使用 async:false 是不好的 - 在 FF 中已知会阻止整个浏览器.想一些其他的方法来做检查:

                  Yes, popups should be a direct result of a user action. Doing them in ajax callback will not do the trick. Also, using async:false is bad - in FF it is known to block the whole browser. Think of some other way to do the check:

                  • 这可能是您在弹出窗口中做的第一件事
                  • 您可以在点击时打开弹出窗口,并在稍后触发回调时对其进行操作
                  • 您可以要求用户再次单击某个按钮来触发弹出窗口(可能是最糟糕的解决方案)
                  • 您可以在页面加载时执行此操作

                  这篇关于如何防止谷歌浏览器阻止我的弹出窗口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:多显示器/双显示器系统上的 window.open() - 窗口在哪里弹出? 下一篇:如何在 Google Chrome 中使用工具栏打开 window.open?

                  相关文章

                2. <legend id='VkHSu'><style id='VkHSu'><dir id='VkHSu'><q id='VkHSu'></q></dir></style></legend>

                    <tfoot id='VkHSu'></tfoot>
                      <bdo id='VkHSu'></bdo><ul id='VkHSu'></ul>

                  1. <small id='VkHSu'></small><noframes id='VkHSu'>

                    1. <i id='VkHSu'><tr id='VkHSu'><dt id='VkHSu'><q id='VkHSu'><span id='VkHSu'><b id='VkHSu'><form id='VkHSu'><ins id='VkHSu'></ins><ul id='VkHSu'></ul><sub id='VkHSu'></sub></form><legend id='VkHSu'></legend><bdo id='VkHSu'><pre id='VkHSu'><center id='VkHSu'></center></pre></bdo></b><th id='VkHSu'></th></span></q></dt></tr></i><div id='VkHSu'><tfoot id='VkHSu'></tfoot><dl id='VkHSu'><fieldset id='VkHSu'></fieldset></dl></div>