<tfoot id='2oIXx'></tfoot>
    1. <small id='2oIXx'></small><noframes id='2oIXx'>

      <legend id='2oIXx'><style id='2oIXx'><dir id='2oIXx'><q id='2oIXx'></q></dir></style></legend>
      <i id='2oIXx'><tr id='2oIXx'><dt id='2oIXx'><q id='2oIXx'><span id='2oIXx'><b id='2oIXx'><form id='2oIXx'><ins id='2oIXx'></ins><ul id='2oIXx'></ul><sub id='2oIXx'></sub></form><legend id='2oIXx'></legend><bdo id='2oIXx'><pre id='2oIXx'><center id='2oIXx'></center></pre></bdo></b><th id='2oIXx'></th></span></q></dt></tr></i><div id='2oIXx'><tfoot id='2oIXx'></tfoot><dl id='2oIXx'><fieldset id='2oIXx'></fieldset></dl></div>

      • <bdo id='2oIXx'></bdo><ul id='2oIXx'></ul>

      1. 如何在另一个窗口中检查打开的 URL?

        How can I check for an open URL in another window?(如何在另一个窗口中检查打开的 URL?)

          <tbody id='I6Fo3'></tbody>

        1. <legend id='I6Fo3'><style id='I6Fo3'><dir id='I6Fo3'><q id='I6Fo3'></q></dir></style></legend>

          <small id='I6Fo3'></small><noframes id='I6Fo3'>

              <bdo id='I6Fo3'></bdo><ul id='I6Fo3'></ul>
            • <i id='I6Fo3'><tr id='I6Fo3'><dt id='I6Fo3'><q id='I6Fo3'><span id='I6Fo3'><b id='I6Fo3'><form id='I6Fo3'><ins id='I6Fo3'></ins><ul id='I6Fo3'></ul><sub id='I6Fo3'></sub></form><legend id='I6Fo3'></legend><bdo id='I6Fo3'><pre id='I6Fo3'><center id='I6Fo3'></center></pre></bdo></b><th id='I6Fo3'></th></span></q></dt></tr></i><div id='I6Fo3'><tfoot id='I6Fo3'></tfoot><dl id='I6Fo3'><fieldset id='I6Fo3'></fieldset></dl></div>
                  <tfoot id='I6Fo3'></tfoot>
                1. 本文介绍了如何在另一个窗口中检查打开的 URL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  这是对我上一个问题的跟进如果窗口不存在则打开一个窗口本质上,我现在保留一个页面已打开的所有窗口引用的列表,并且仅在它们尚未打开时才允许打开它们.然后我遇到了一个潜在的问题 - 用户当然可以关闭原始窗口,然后再次打开它,从而丢失窗口引用列表.

                  This is a follow up to my last question Open a window if the window does not already exist Essentially, I am now keeping a list of all the window references that have been opened by a page, and only allowing them to be opened if they are not already open. Then a potential problem struck me - it is of course possible for a user to shut down the original window, and open it again, thus losing the list of window references.

                  是否可以循环浏览在浏览器中打开的窗口,检查特定的 URL?

                  Is it possible to loop through the windows open in a browser, checking for a particular URL?

                  在这里(以及其他问题)提供了很多有用的评论之后,这里是应用程序启动器的最终代码.本质上,它尝试使用适当的名称获取打开窗口的位置.如果这导致异常(由于隐私问题),则判断应用程序已加载.如果它是about:blank",那么它是一个新窗口.这适用于 Firefox、IE7 和 Google Chrome.感觉很脏……

                  After a lot of helpful comments here (and on the other question), here is the final code for the application launcher. Essentially, it tries to get the location of the open window with the appropriate name. If that causes an exception (because of a privacy issue), then the application is judged to have been loaded. If it is "about:blank", then it is a new window. This works on Firefox, IE7 and Google Chrome. It feels dirty...

                  var g_urlarray = [];
                  
                  Array.prototype.has = function(value) {
                      var i;
                      for (var i in this) {
                          if (i === value) {
                              return true;
                          }
                      }
                      return false;
                  };
                  
                  
                  function launchApplication(l_url, l_windowName)
                  {
                      var l_width = screen.availWidth;
                      var l_height = screen.availHeight;
                      var winRef;
                  
                      var l_params = 'status=1' +
                          ',resizable=1' +
                          ',scrollbars=1' +
                          ',width=' + l_width +
                          ',height=' + l_height +
                          ',left=0' +
                          ',top=0';
                      if (g_urlarray.has(l_url)) {
                          winRef = g_urlarray[l_url];
                      }
                      if (winRef == null || winRef.closed) {
                          winRef = window.open('', l_windowName, l_params);
                          var l_openNew = 0;
                          try {
                              if (winRef.location == 'about:blank') {
                                  l_openNew = 1;
                              }
                          }
                          catch (e) {
                              l_openNew = 0;
                          }
                          if (l_openNew === 1)
                          {
                              winRef.location = l_url;
                              winRef.moveTo(0,0);
                              winRef.resizeTo(l_width, l_height);
                          }
                          g_urlarray[l_url] = winRef;
                      }
                  }
                  

                  推荐答案

                  @annakata(即使你存储了它们,你也无权关闭它们)

                  @annakata (and even if you stored them, you wouldn't have permission to close them any more)

                  不正确.如果您有窗口的名称,您可以使用 window.open 重新建立到窗口的链接,即使打开器已关闭并重新打开.例如:

                  Not true. If you have the name of the window, you can use window.open to reestablish a link to the window even if the opener was closed and reopened. For example:

                  <script>
                  function winOpen(url){
                    return window.open(url,getWinName(url));
                  }
                  function winClose(url){
                    var win = window.open("",getWinName(url));
                    win.close();
                  }
                  function getWinName(url){
                    return "win" + url.replace(/[^A-Za-z0-9-\_]*/g,"");
                  }
                  </script>
                  <a href="#" onclick="winOpen('http://google.com');return false;">Click me first</a>, close and open this window, then
                  <a href="#" onclick="winClose('http://google.com');return false;">click me to close the other window</a>
                  

                  这篇关于如何在另一个窗口中检查打开的 URL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Fetch multiple links inside foreach loop(在 foreach 循环中获取多个链接)
                  Backbone Fetch Request is OPTIONS method(Backbone Fetch Request 是 OPTIONS 方法)
                  Fetch API leaks memory in Chrome(Fetch API 在 Chrome 中泄漏内存)
                  How can I download and save a file using the Fetch API? (Node.js)(如何使用 Fetch API 下载和保存文件?(Node.js))
                  Send blob data to node using fetch, multer, express(使用 fetch、multer、express 将 blob 数据发送到节点)
                  Sending a custom User-Agent string along with my headers (fetch)(发送自定义用户代理字符串以及我的标头(获取))
                2. <i id='WNHmg'><tr id='WNHmg'><dt id='WNHmg'><q id='WNHmg'><span id='WNHmg'><b id='WNHmg'><form id='WNHmg'><ins id='WNHmg'></ins><ul id='WNHmg'></ul><sub id='WNHmg'></sub></form><legend id='WNHmg'></legend><bdo id='WNHmg'><pre id='WNHmg'><center id='WNHmg'></center></pre></bdo></b><th id='WNHmg'></th></span></q></dt></tr></i><div id='WNHmg'><tfoot id='WNHmg'></tfoot><dl id='WNHmg'><fieldset id='WNHmg'></fieldset></dl></div>

                  <tfoot id='WNHmg'></tfoot>

                    <bdo id='WNHmg'></bdo><ul id='WNHmg'></ul>
                          <tbody id='WNHmg'></tbody>

                          1. <legend id='WNHmg'><style id='WNHmg'><dir id='WNHmg'><q id='WNHmg'></q></dir></style></legend>

                            <small id='WNHmg'></small><noframes id='WNHmg'>