//窗体打开 var newWindow=Window.open("default.html","windowName","height=200,width=300,..(其余参数)")://height和widht为空默认会打开一个新选项卡 //窗体关闭 newWindow.close(); //窗体的location newWindow.location.herf="http://www.baidu.com";
//提示框 alert("some text here"); //带返回值的 if(confirm("are you sure?")){ //do some thing} //带输入框的 var result=prompt("what is your name?") if(result){//do something}
navigator.userAgent包含浏览器不少的细节
好比chrome的userAgent内容有javascript
document.write(navigator.userAgent); //输出入下 Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36
navigator.appVersion
5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36
html
document.forms[]
引用其中一个表单能够使用document.forms[0]
或者document.forms["formName"]
java
document.images[]
document对象保持了一个以标记方式插入到文档中的图像的集合,经过
document.images
能够得到imag元素chrome
document.write()
在载入页面后,浏览器输出流自动关闭,再次以后任何一个对当前页面进行操做的document.write()
都将打开一个新的输出流,会清空当前页面内容。因此须要吧HTML内容链接起来赋值给一个变量。须要注意的是document.write()
相关的方法document.close()
,若是没有进行关闭,连续的document.write()
只会连续添加到后面不会清除当前值,若是不添加close方法,就不能显示图像和表单。数组
document.createElement()
和document.createTextNode()
document.createElement()
在浏览器内存中中建立一个新元素对象
如var p=document.createElement("p")
document.createTextNode()
建立一个新文本节点浏览器
以上操做并不影响原本的文档节点树,须要调用各类插入和替换方法才能将元素放入文档中。app
document.getElementById('idName')
获取id为idName的元素