• <bdo id='qgEv0'></bdo><ul id='qgEv0'></ul>
    <tfoot id='qgEv0'></tfoot>

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

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

        JavaScript localStorage 对象在 Windows 7 上的 IE11 中损坏

        时间:2023-08-01
          <tbody id='mPNOI'></tbody>
        <legend id='mPNOI'><style id='mPNOI'><dir id='mPNOI'><q id='mPNOI'></q></dir></style></legend>
        1. <small id='mPNOI'></small><noframes id='mPNOI'>

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

                  <i id='mPNOI'><tr id='mPNOI'><dt id='mPNOI'><q id='mPNOI'><span id='mPNOI'><b id='mPNOI'><form id='mPNOI'><ins id='mPNOI'></ins><ul id='mPNOI'></ul><sub id='mPNOI'></sub></form><legend id='mPNOI'></legend><bdo id='mPNOI'><pre id='mPNOI'><center id='mPNOI'></center></pre></bdo></b><th id='mPNOI'></th></span></q></dt></tr></i><div id='mPNOI'><tfoot id='mPNOI'></tfoot><dl id='mPNOI'><fieldset id='mPNOI'></fieldset></dl></div>
                  本文介绍了JavaScript localStorage 对象在 Windows 7 上的 IE11 中损坏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  Internet Explorer 11(Windows 7 版本)中的 localStorage 对象包含某些函数的字符串表示,而不是您所期望的本机调用.

                  The localStorage object in Internet Explorer 11 (Windows 7 build) contains string representations of certain functions instead of native calls as you would expect.

                  这只会与普通 JavaScript 中断,像 JSFiddle 这样的网站对此代码没有问题,但我怀疑这是因为有 localStorage 可以纠正它.

                  This only breaks with vanilla JavaScript and sites like JSFiddle have no problem with this code but I suspect it's because there are localStorage polyfills in place that correct it.

                  以这个HTML页面代码为例:

                  Take this HTML page code for example:

                  <!DOCTYPE html>
                  <script>
                    localStorage.setItem('test', '12345');
                    alert(localStorage.getItem('test'));
                    localStorage.clear();
                  </script>
                  

                  这在我安装的所有浏览器中都运行良好,除了 IE11.第一行 'SCRIPT5002: Function expected' 出现错误.

                  This works perfectly well in all my installed browsers except for IE11. An error occurs on the first line 'SCRIPT5002: Function expected'.

                  看看setItem函数在IE开发者工具控制台中实际是什么类型,说明它是一个字符串...?

                  Taking a look at what type the setItem function actually is in the IE developer tools console, states that it's a string...?

                      typeof localStorage.setItem === 'string' // true
                  

                  打印出 setItem 的字符串显示如下:

                  Printing out the string for setItem displays the following:

                  "function() {
                  var result;
                  callBeforeHooks(hookSite, this, arguments);
                  try {
                  result = func.apply(this, arguments);
                  } catch (e) {
                  callExceptHooks(hookSite, this, arguments, e);
                  throw e;
                  } finally {
                  callAfterHooks(hookSite, this, arguments, result);
                  }
                  return result;
                  }"
                  

                  奇怪的是,并不是所有的函数都被字符串替换了,例如,对应的getItem函数确实是一个函数,并且按预期工作.

                  Oddly enough, not all functions have been replaced with strings, for example, the corresponding getItem function is indeed a function and works as expected.

                      typeof localStorage.getItem === 'function' // true
                  

                  将文档模式(模拟)更改为 10 或 9 仍然不能解决问题,并且都会导致相同的错误.将文档模式更改为 8 会出现以下错误对象不支持此属性或方法",这是预期的,因为 IE8 不支持 localStorage.

                  Changing the document mode (emulation) to 10 or 9 still doesn't resolve the problem and both result in the same error. Changing the document mode to 8 gives the following error 'Object doesn't support this property or method' which is expected since IE8 doesn't support localStorage.

                  是否有其他人在 Windows 7 上遇到与 IE11 相同的问题,其中 localStorage 对象似乎损坏/损坏"?

                  Is anyone else having the same issue with IE11 on Windows 7 where the localStorage object seems 'broken/corrupt'?

                  推荐答案

                  原来这是 Windows 7 SP1 的基本版本 IE11 (11.0.9600.16428) 中的问题.

                  Turns out this is a problem in the base version of IE11 (11.0.9600.16428) for Windows 7 SP1.

                  安装补丁后更新到11.0.9600.16476(更新版本 11.0.2 - KB2898785)问题得到解决.可以在 补丁下载页面.

                  After installing a patch to update to 11.0.9600.16476 (update version 11.0.2 - KB2898785) the issue gets resolved. Links to other versions of Windows (32-bit etc.) can be found at the bottom of the patch download page.

                  这篇关于JavaScript localStorage 对象在 Windows 7 上的 IE11 中损坏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                      <tbody id='vngtN'></tbody>

                      <tfoot id='vngtN'></tfoot>

                        <bdo id='vngtN'></bdo><ul id='vngtN'></ul>
                        • <legend id='vngtN'><style id='vngtN'><dir id='vngtN'><q id='vngtN'></q></dir></style></legend>
                        • <small id='vngtN'></small><noframes id='vngtN'>

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