建站软件 优化软件 编程软件 网页辅助 站群程序 网站程序 图像处理 资源教程 字体下载 推荐软件


您的位置:首页 > javascript学习 > javascript之Document对象的属性

javascript之Document对象的属性

时间:2015-01-21 11:34:49  来源:免费模板网 作者:风雪 阅读次数 tagsjavascript之Document对象的属性

对象属性
  Document.title 设置文档标题等价于<title>标签。
  Document.bgcolor 背景颜色
  Document.fgcolor 前景颜色(文本颜色)
  Document.linkcolor 未点击的连接颜色  Document.alinkcolor 焦点在连接上的颜色
  Document.vlinkcolor点击过后的连接颜色  
Document.charset 字符集
Document.cookie 设置和读取cookie
 
常用方法
  Document.write();
  Document.createElement(Tag); //创建一个html标签对象.
  Document.getElementById(id) //获取指定ID值的对象。
  Document.getElementsByName(name) //获取指定Name值的对象。
  
Document.body //<body ></body>
Document.body.link
Document.body.alink
Document.body.vlink
Document.body.text
Document.body.leftMargin
Document.body.rightMargin
Document.body.topMargin
Document.body.bottomMargin
Document.body.background
 
Document.body.innerText //在<body>文本内容</body>
Document.body.innerHTML //在<body>HTML代码</body>
 
 
Document.body.appendChild(Tag);//绑定一个对象到正文部分
 
常用事件
Document.body.onclick = “”
Document.body.onmouseover = “”
Document.body.onmouseout = “”
 
=================
HTML DOM
 
 
DOM (Document Object model)文档对象模型
DOM树结构:
Document – 最顶层的节点,其他节点都附属于它。
DocumentType -  DTD引用节点
DocumentFragment – 碎片文档
Element – 表示起始标签到结束标签之间的内容
Attr – 表示属性名和内容
Text 表示标签之间的文本内容
CDataSection – 节点
Entity – Entity定义节点
EntityReference – 实体引用节点
ProcessingInstruction – PI节点
Comment 注释节点
Notation – DTD规范中定义的记号
 
创建节点的方法
createElement(tagname) 创建一个标签名为tagname的元素
createTextNode(text) 创建一个包含文本text的文本节点
appendChild(节点对象) 添加节点
 
removeChild(节点对象) 删除节点对象
删除当前节点的子节点,返回删除的节点。这个被删除的节点可以被插入到其他地方。
节点的parentNode特性
 
replaceChild(节点1,节点2)用节点1替换节点2。
 
insertBefore(节点1,节点2)在节点2之前插入节点1.
 
cloneNode(deepBoolean)复制节点,复制了原节点的属性,在把这个新节点插入到document前需要修改ID属性确保ID值唯一。
布尔参数 deepBoolean 为true时,复制当前节点的所有子节点,包括该节点内的文本。
 
 
Node接口 attributes方法 
注意,只有element节点才能具有该特性。
getNamedItem(name) 返回nodename属性值等于name的节点
setNamedItem(node)
 
NameNodeMap对象 length 包含节点数量的。
<p style=”color:red” id=”p1”>nihao</p>
Var pp = document.getElementById(“p1”);
pp.attributes.getNamedItem(“id”).nodevalue = “yy”;
pp.attributes.item(0).nodevalue
 
getAttribute(name)
setAttribute(name,value)
 
getElementsByTagName();
 
 
Javascript操作xml  例:testxml.html
 
XMLHttpRequest对象
创建XMLHttpRequest对象的语法:
  xmlhttp =  new XMLHttpRequest();
 
xmlhttp =  new ActiveXObject("Microsoft.XMLHTTP ");
 
OPEN(“GET、POST”,url,true);
Send()
 
 

本文地址:https://www.freemoban.com/javascript/2015/0121/250.html

猜你喜欢
栏目推荐
模板推荐

Copyright:www.freemoban.com 免费模板网 All Rights Reserved 网站备案:辽ICP备19014872号-2   辽公网安备 21010602000376号  辽公网安备:42900402000182号

免责声明:本站部分资源来自互联网收集,版权归原创者所有,如果侵犯了你的权益,我们会及时删除侵权内容,联系QQ:1615187561 谢谢合作!