<tfoot id='DOllM'></tfoot>

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

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

        <legend id='DOllM'><style id='DOllM'><dir id='DOllM'><q id='DOllM'></q></dir></style></legend>
        <i id='DOllM'><tr id='DOllM'><dt id='DOllM'><q id='DOllM'><span id='DOllM'><b id='DOllM'><form id='DOllM'><ins id='DOllM'></ins><ul id='DOllM'></ul><sub id='DOllM'></sub></form><legend id='DOllM'></legend><bdo id='DOllM'><pre id='DOllM'><center id='DOllM'></center></pre></bdo></b><th id='DOllM'></th></span></q></dt></tr></i><div id='DOllM'><tfoot id='DOllM'></tfoot><dl id='DOllM'><fieldset id='DOllM'></fieldset></dl></div>
      1. 如何仅在 IE 中加载脚本

        How to load a script only in IE(如何仅在 IE 中加载脚本)
          • <tfoot id='vvPgt'></tfoot>
              <tbody id='vvPgt'></tbody>

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

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

                <bdo id='vvPgt'></bdo><ul id='vvPgt'></ul>
                  <legend id='vvPgt'><style id='vvPgt'><dir id='vvPgt'><q id='vvPgt'></q></dir></style></legend>

                • 本文介绍了如何仅在 IE 中加载脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我只需要在 Internet Explorer 浏览器中触发特定脚本!

                  I need a particular script to be triggered in Internet Explorer browsers Only!

                  我试过了:

                  <!--[if IE]> 
                  <script></script>
                  <![endif]-->
                  

                  不幸的是,这实际上阻止了脚本的加载.

                  Unfortunately this actually stops the script from being loaded.

                  对于问我为什么需要这个的每个人:IE 在使用某些动画时会使滚动变得非常跳跃.为了解决这个问题,我需要实现一个为 IE 提供平滑滚动的脚本.我不想将它应用到其他浏览器,因为它们不需要它,而且这个脚本虽然使滚动更平滑也让它有点不自然.

                  For everyone asking why I need this: IE makes scrolling extremely jumpy when using some animations. In order to address this I need to implement a script that provides smooth scrolling to IE. I don't want to apply it to other browsers as they don't need it and this script although making the scrolling smoother also makes it a bit unnatural.

                  推荐答案

                  我很好奇为什么你特别需要针对 IE 浏览器,但是如果你确实需要这样做,下面的代码应该可以工作:

                  I'm curious why you specifically need to target IE browsers, but the following code should work if that really is what you need to do:

                  <script type="text/javascript">
                      if(/MSIE d|Trident.*rv:/.test(navigator.userAgent))
                          document.write('<script src="somescript.js"></script>');
                  </script>
                  

                  Regex 的前半部分 (MSIE d) 用于检测 Internet Explorer 10 及以下版本.后半部分用于检测IE11(Trident.*rv:).

                  The first half of the Regex (MSIE d) is for detecting Internet Explorer 10 and below. The second half is for detecting IE11 (Trident.*rv:).

                  如果浏览器的用户代理字符串与该模式匹配,它会将 somescript.js 附加到页面.

                  If the browser's user agent string matches that pattern, it will append somescript.js to the page.

                  这篇关于如何仅在 IE 中加载脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  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)(发送自定义用户代理字符串以及我的标头(获取))
                • <i id='oLoHa'><tr id='oLoHa'><dt id='oLoHa'><q id='oLoHa'><span id='oLoHa'><b id='oLoHa'><form id='oLoHa'><ins id='oLoHa'></ins><ul id='oLoHa'></ul><sub id='oLoHa'></sub></form><legend id='oLoHa'></legend><bdo id='oLoHa'><pre id='oLoHa'><center id='oLoHa'></center></pre></bdo></b><th id='oLoHa'></th></span></q></dt></tr></i><div id='oLoHa'><tfoot id='oLoHa'></tfoot><dl id='oLoHa'><fieldset id='oLoHa'></fieldset></dl></div>
                    <tbody id='oLoHa'></tbody>

                      <legend id='oLoHa'><style id='oLoHa'><dir id='oLoHa'><q id='oLoHa'></q></dir></style></legend>
                        <bdo id='oLoHa'></bdo><ul id='oLoHa'></ul>

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

                        • <tfoot id='oLoHa'></tfoot>