浏览 136 次
|
该帖已经被评为新手帖
|
|
|---|---|
| 作者 | 正文 |
|
最后更新时间:2008-05-20
有这样两个页面: a.htm
<html>
<head>
<script>
function f1( p)
{
alert ( " type is "+ typeof p);
alert( " is Object :" + ( p instanceof Object));
alert( " is Array : " + ( p instanceof Array));
}
function test()
{
var f= document.frames("frame1");
var p= f.getData();
f1( p);
}
</script>
</head>
<body>
<input type="button" value="test" onclick="test();">
<iframe id=frame1 width="100%" height="200" src="b.htm"></iframe>
</body>
</html>
页面 b.htm
<html>
<head>
<script>
function getData( )
{
var p=[];
p[p.length]='abc';
p[p.length]='def';
alert ( " type is "+ typeof p);
alert( " is Object :" + ( p instanceof Object));
alert( " is Array : " + ( p instanceof Array));
return p;
}
</script>
</head>
<body>
a iframe
</body>
</html>
用浏览器打开 a.htm ,点击其中的 test按钮, 大家看一下提示信息,相当奇怪。 分别是: type is object is Object: true is Array :true type is object is Object: false is Array :false 为什么对象做为参数传给parent窗口后,类型检测会出现不同的结果。 声明:JavaEye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
|
|
| 返回顶楼 | |


