1 Browser对象
Window : closed
Navigator
Screen
History
Location
2 Document
集合:
window.document
document.all[i] , document.all[name] , document.all.tags[tagname]
document.anchors[] , document.anchors.length , document.anchors[0].innerHTML
document.forms[] , document.forms.length , document.forms[0].name , document.getElementById("form1").name
document.images[] 不包含由<object>标记定义的图像
document.images.length
document.links[] 返回文档中所有Area和Link对象的引用 , document.link[0].id
属性:
body
document.cookie
document.domain
document.lastModified
document.referrer
document.title
document.URL
方法
document.close()
document.getElementById("maindiv")
document.ElementsByName("xiaoxiao")
document.getElementsByTagName("input")
document.open(mimetype, replace); mimetype : 文档类型,默认 "text/html"; replace : 参数设置后,可引起新文 档从父文档继承历史条目
重要事项:调用 open() 方法打开一个新文档并且用 write() 方法设置文档内容后,必须记住用 close 方法关闭文档,并迫使其内容显示出来。
<html>
<head>
<script type="text/javascript">
function createNewDoc()
{
var newDoc=document.open("text/html","replace");
var txt="<html><body>Learning about the DOM is FUN!</body></html>";
newDoc.write(txt);
newDoc.close();
}
</script>
</head>
<body>
<input type="button" value="Write to a new document"
οnclick="createNewDoc()">
</body>
</html>
<html>
<head>
<script type="text/javascript">
function winTest()
{
var txt1 = "This is a new window.";
var txt2 = "This is a test.";
win.document.open("text/html","replace");
win.document.writeln(txt1);
win.document.write(txt2);
win.document.close();
}
</script>
</head>
<body>
<script type="text/javascript">
var win=window.open('','','width=200,height=200');
winTest();
</script>
</body>
</html>
document.write(exp1, exp2, exp3) : 向输出流写文本,HTML, 或多参数使用
document.writeln() 与write()不同的是换行
Document 对象属性及方法小结
最新推荐文章于 2024-01-01 23:37:03 发布