汇编网首页登录博客注册
xiaofkg的学习博客
博客首页博客互动【做检测题】论坛求助

我的博客

个人首页 |  我的文章 |  我的相册 |  我的好友 |  最新访客 |  文章收藏 |  论坛提问 |  友情链接 |  给我留言  
图片载入中
学习动态
好友圈
文章收藏
友情链接

[2009-09-03 15:08] document.open 与 window.open的区别

An important point about the open() method is that it is almost always invoked as window.open(), even though window refers to the global object and should therefore be entirely optional. Since the document object also has an open() method, specifying the window object when we want to open a new window is essential for clarity. In event handlers, you must specify window.open() instead of simply using open(). Due to the scoping of static objects in JavaScript, a call to open() without specifying an object name is equivalent to document.open(). When the event handler of an HTML button executes, for example, the scope chain includes the Button object, the Form object, the Document object, and finally, the Window object that contains the document. Thus, if such an event handler refers to the open() method, this identifier ends up being resolved in the Document object, and the event handler opens a new document instead of opening a new window.

document.open 一般为document.write或document.writeln写入流做准备的
document.close强制显示输入流。
评论次数(0)  |  浏览次数(685)  |  类型(心得体会) |  收藏此文  | 
 
 请输入验证码  (提示:点击验证码输入框,以获取验证码