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

          <bdo id='Xpw4j'></bdo><ul id='Xpw4j'></ul>

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

      2. <legend id='Xpw4j'><style id='Xpw4j'><dir id='Xpw4j'><q id='Xpw4j'></q></dir></style></legend>
      3. 检测浏览器对跨域 XMLHttpRequests 的支持?

        时间:2023-10-14

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

          <tbody id='JiAKa'></tbody>

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

              <tfoot id='JiAKa'></tfoot>

                <legend id='JiAKa'><style id='JiAKa'><dir id='JiAKa'><q id='JiAKa'></q></dir></style></legend>
                • <bdo id='JiAKa'></bdo><ul id='JiAKa'></ul>
                  本文介绍了检测浏览器对跨域 XMLHttpRequests 的支持?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我正在开发一些 Javascript,它利用 Firefox 3.5 执行跨域 XMLHttpRequests 的能力……但如果它们不受支持,我想优雅地失败.

                  I'm working on some Javascript that makes use of Firefox 3.5's ability to perform cross-domain XMLHttpRequests… But I'd like to fail gracefully if they aren't supported.

                  除了实际发出跨域请求外,还有什么方法可以检测浏览器对它们的支持吗?

                  Apart from actually making a cross-domain request, is there any way to detect a browser's support for them?

                  推荐答案

                  为了将来参考,完整的 CORS 特征检测应该如下所示:

                  For future reference, full CORS feature detection should look something like this:

                  //Detect browser support for CORS
                  if ('withCredentials' in new XMLHttpRequest()) {
                      /* supports cross-domain requests */
                      document.write("CORS supported (XHR)");
                  }
                  else if(typeof XDomainRequest !== "undefined"){
                    //Use IE-specific "CORS" code with XDR
                    document.write("CORS supported (XDR)");
                  }else{
                    //Time to retreat with a fallback or polyfill
                    document.write("No CORS Support!");
                  }
                  

                  您可以使用 JSBin 进行现场测试,并在 IE、Firefox、Chrome、Safari 和歌剧.

                  You can try this test live using JSBin and see the proper response in IE, Firefox, Chrome, Safari, and Opera.

                  在非浏览器环境中存在一些支持跨域 XHR 但不支持 XHR2/CORS 的边缘案例.此测试不考虑这些情况.

                  There are some edge cases in non-browser environments that do support cross-domain XHR but not XHR2/CORS. This test does not account for those situations.

                  这篇关于检测浏览器对跨域 XMLHttpRequests 的支持?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:纯 Javascript 中的 AJAX 后期实现 下一篇:XMLHttpRequest 的 onerror 处理程序应该何时触发

                  相关文章

                  最新文章

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

                • <small id='qhwGA'></small><noframes id='qhwGA'>

                  • <bdo id='qhwGA'></bdo><ul id='qhwGA'></ul>

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