网络编程
位置:首页>> 网络编程>> JavaScript>> Javascript:window对象出身何处

Javascript:window对象出身何处

作者:veking 来源:csdn 发布时间:2007-08-28 15:16:00 

标签:window,javascript

注:文中未表明的地方output 输出都是基于IE6.0,其中表明FF的地方为Mozilla Firefox2.0,还要注意文中的大小写

javascript的构成有三部分:ECMAScript、DOM和BOM

1、其中ECMAScript中所有的对象都是Object对象的实例,下面的例子可以说明问题:

alert(Function instanceof  Object);  //output "true"
alert(String instanceof  Object);  //output "true"


2、DOM只是一个API与任何语言无关,它所有的操作都是基于document即文档,看下面的例子:

<div id="test">aaa</div>
<script type="text/javascript">  
alert(document.getElementById("test").innerHTML);  //output "aaa"
alert(window.document.getElementById("test").innerHTML);  //output "aaa"
alert(Document instanceof Window);  //nothing output (no error)  FF output "false"
</script>


 3、BOM(浏览器对象模型)包括:document frames history location navigator screen 对象

alert(location instanceof Window);  //nothing output (no error) FF output "false"


抱着最后的希望,再来看一个例子:

alert(Window instanceof Object); //nothing output (no error) FF output "true"


从以上几个例子可以看到,微软完全是自行一套实现的它的javascript(即JScript),和标准相去甚远,就算是
现在的IE7.0也是如此,唉,还是睡觉吧!

补充:可以看出FF的window对象是基于Object对象继承来的,那微软的window对象从和而来呢?说实话到现在我也没弄清楚它是从何而来,真是令人费解啊,如果有谁能知道答案请告诉我一下,谢谢先!

0
投稿

猜你喜欢

手机版 网络编程 asp之家 www.aspxhome.com