在我的代码中的某个时刻,我以这种方式访问javascript变量:
var DASHBOARD = document.parentWindow.parent.Dashboard;
父亲的值是{object Window},其类型是DispHTMLWindow2。 它在IE8或IE9兼容性视图中工作正常,但是当我无法在IE9上工作时。
在IE9上,document.parentWindow.parent.Dashboard的值未定义,其类型为Undefined。我还注意到,父级的值为{...},其类型为IE 9上的[Object,Window]。
在IE 9中有不同的方式访问变量Dashboard吗?
示例:
layouts.aspx
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Create new Layout</title>
<style type="text/css">
.border-top { height: 5px; background-color: #B2B2B2;}
.border-left { width: 3px; height: 100%; background-color: #B2B2B2;}
.content { height: 100%; background-color: #FFFFFF;}
</style>
<script type="text/javascript" src="./container/includes/js/jquery-1.5.1.min.js"></script>
<script type="text/javascript" src="./container/includes/js/jquery-ui-1.8.12.custom.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
var dada = "123";
});
</script>
</head>
<body>
<form id="form1" runat="server" style="width: 100%; height: 100%;">
<div style="width: 100%; height: 100%;">
<iframe name="remote_iframe_0" src="layouts2.aspx" id="remote_iframe_0" />
</div>
</form>
</body>
</html>
layouts2.aspx
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.border-top { height: 5px; background-color: #B2B2B2;}
.border-left { width: 3px; height: 100%; background-color: #B2B2B2;}
.content { height: 100%; background-color: #FFFFFF;}
</style>
<script type="text/javascript" src="./container/includes/js/jquery-1.5.1.min.js"></script>
<script type="text/javascript" src="./container/includes/js/jquery-ui-1.8.12.custom.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
debugger;
});
</script>
</head>
<body>
<form id="form1" runat="server" style="width: 100%; height: 100%;">
<div style="width: 100%; height: 100%;">
AAAA
</div>
</form>
</body>
</html>
如何在调试器中访问变量dada;在layouts2.aspx?考虑两个页面都在同一个域中。