Document 对象属性及方法小结

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()不同的是换行

	

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值