Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/440.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在IE8/IE9中的HTML框架之间共享JS对象_Javascript_Html_Internet Explorer_Compatibility - Fatal编程技术网

Javascript 在IE8/IE9中的HTML框架之间共享JS对象

Javascript 在IE8/IE9中的HTML框架之间共享JS对象,javascript,html,internet-explorer,compatibility,Javascript,Html,Internet Explorer,Compatibility,我必须为一个专门为IE6构建的应用程序提供对IE8/IE9的支持,该应用程序大量使用HTML框架集。应用程序在使用navigator.PropertyABC的地方有很多JavaScript代码。这里,PropertyABC是一个在其中一个帧中初始化并在许多其他帧中使用的对象。这在IE6中起作用,因为导航器对象在IE6中似乎在所有帧之间共享。它还与IE7兼容模式一起工作。但它在IE8/IE9中不起作用。 有嵌套在其他帧中的帧,因此它是多层次的。 示例代码: <html> <f

我必须为一个专门为IE6构建的应用程序提供对IE8/IE9的支持,该应用程序大量使用HTML框架集。应用程序在使用navigator.PropertyABC的地方有很多JavaScript代码。这里,PropertyABC是一个在其中一个帧中初始化并在许多其他帧中使用的对象。这在IE6中起作用,因为导航器对象在IE6中似乎在所有帧之间共享。它还与IE7兼容模式一起工作。但它在IE8/IE9中不起作用。 有嵌套在其他帧中的帧,因此它是多层次的。 示例代码:

<html>
  <frameset rows="50%,50%">
    <frame name="a" src="frame1.html">
    <frame name="b" src="frame2.html">
  </frameset>
</html>
frame1.html:

<html>
  <body>
    <script type="text/javascript">
        navigator.testingSharedVariable ="1st frame!";
    </script>
  </body>
</html>
frame2.html:

<html>
  <body>
    <input type="button" onclick="alert(navigator.testingSharedVariable)">
  </body>
</html>
当点击IE6中的按钮时-第一帧警报!这是提高。在IE8/IE9上-未定义

还有什么可以用来在帧之间共享对象而不是导航器的吗?
不需要其他浏览器支持,只需要IE8/IE9。

使用标准的全局对象窗口。在您的情况下,共享全局对象本身就是一个窗口。

明智的客户不会从过去的错误中吸取教训:-