微信标志

JAVAscript练习

东山群-电脑网络技术
1、window.open & write



先清空,再写入。

2、window.close

3、window.navigator.userAgent & window.location



记录

window.open:基本写法window.open('about:blank'),被执行后是新开启一个空白页。open是有返回值的,他返回的就是新打开的窗口的内容。例如:var newWindow=window.open('about:blank', '_blank');

write:基本写法document.write('abc'),被执行后是先把页面所有内容清空,然后再写入他的参数内容。

document:完整写法是window.document,window是可以省略的。因为document必然属于window。所以在open新窗口之后,新窗口也有document。例如:newWindow.document.write(aTxt2.value);

window.close:基本写法window.close(),只能关闭由window.open打开的窗口。

window.navigator.userAgent:获取当前浏览器的版本信息。

window.location:获取当前页面的地址。不光可以获取,还可以赋值。例如:window.location='http://www.baidu.com/'