我有示例代码来证明我的工作
尝试将代码更改为最新的即版本,但是在ie10
上我在index.html上创建了对象 并传递给父frame1.html
frame1.html传递给frame2.html这个页面仍然设置/获取数据
frame2.html打开pageX.html
尝试在pageX上设置值但可以获得值时会发生问题 当调用函数设置值页面显示错误函数预期
此代码仍适用于ie9
我不知道ie9到ie10
之间的对象行为变化这是我的样本 它有4个html
的index.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
<html>
<head>
<meta http-equiv="Content-type" content="text/html;charset=UTF-8">
<title> New Document </title>
<script type="text/javascript">
var zo_gbl_data = new Object ( );
</script>
</head>
<frameset>
<frame src='frame1.html'>
</frameset>
</html>
frame1.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-type" content="text/html;charset=UTF-8">
<title></title>
<script type="text/javascript">
var zo_gbl_data = parent . zo_gbl_data;
function initObj() {
zo_gbl_data . data_lv1 = new Object();
zo_gbl_data . data_lv1 . data = 0;
}
function getObjectLv1() {
alert(zo_gbl_data . data_lv1 . data);
}
function setObjectLv1() {
zo_gbl_data . data_lv1 . data += 1;
}
initObj();
</script>
</head>
<body>
<input type='button' value='Set Object lv1' onclick='setObjectLv1()'><br>
<input type='button' value='Get Object lv1' onclick='getObjectLv1()'><br>
<input type='button' value='open menu' onclick='window.open("frame2.html", "_self")'>
<input type='button' value='open Page' onclick='window.open("pageX.html", "", "", true)'>
</body>
</html>
frame2.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-type" content="text/html;charset=UTF-8">
<title></title>
<script type="text/javascript">
var zo_gbl_data = getGbData();
function getGbData() {
return ( parent . zo_gbl_data );
}
function getData() {
var lo_data;
lo_data = zo_gbl_data;
alert(lo_data . data_lv1 . data);
}
function setObjectLv1() {
var lo_data;
lo_data = zo_gbl_data ;
lo_data . data_lv1 . data += 1;
}
</script>
</head>
<body>
<input type='button' value='Get Opener' onclick='getData()'><br>
<input type='button' value='set Data' onclick='setObjectLv1()'><br><br>
<input type='button' value='open Page' onclick='window.open("pageX.html", "", "", true)'>
</body>
</html>
pageX.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-type" content="text/html;charset=UTF-8">
<title></title>
<script type="text/javascript">
var zo_gbl_data = getGbData();
function getGbData() {
return ( opener . zo_gbl_data );
}
function getData() {
var lo_data;
lo_data = zo_gbl_data ;
alert(lo_data . data_lv1 . data);
}
function setObjectLv1() {
var lo_data;
lo_data = zo_gbl_data ;
lo_data . data_lv1 .data += 1;
}
</script>
</head>
<body>
<input type='button' value='Get Opener' onclick='getData()'><br>
<input type='button' value='set Opener' onclick='setObjectLv1()'><br>
</body>
</html>