document对象_第1页
document对象_第2页
document对象_第3页
document对象_第4页
document对象_第5页
已阅读5页,还剩6页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、document对象document 文挡对象 - JavaScript脚本语言描述-注:页面上元素name属性和JavaScript引用的名称必须一致包括大小写   否则会提示你一个错误信息 "引用的元素为空或者不是对象"-对象属性document.title             /设置文档标题等价于HTML的标签document.bgColor  &

2、#160;        /设置页面背景色document.fgColor           /设置前景色(文本颜色document.linkColor         /未点击过的链接颜色document.alinkColor       

3、60;/激活链接(焦点在此链接上的颜色document.vlinkColor        /已点击过的链接颜色document.URL               /设置URL属性从而在同一窗口打开另一网页document.fileCreatedDate   /文件建立日期,只读属性document.fileModifiedDate&#

4、160; /文件修改日期,只读属性document.fileSize          /文件大小,只读属性 字节document.cookie            /设置和读出cookiedocument.charset           /设置字符集&

5、#160;简体中文:gb2312-常用对象方法document.write(                  /动态向页面写入内容document.createElement(Tag       /创建一个html标签对象document.getElementById(ID      &

6、#160;/获得指定ID值的对象document.getElementsByName(Name  /获得指定Name值的对象document.body.appendChild(oTag-body-主体子对象document.body               /指定文档主体的开始和结束等价于document.body.bgColor       /设置或获

7、取对象后面的背景颜色document.body.link          /未点击过的链接颜色document.body.alink         /激活链接(焦点在此链接上的颜色document.body.vlink         /已点击过的链接颜色document.body.text  

8、        /文本色document.body.innerText     /设置.之间的文本document.body.innerHTML     /设置.之间的HTML代码document.body.topMargin     /页面上边距document.body.leftMargin    /页面左边距documen

9、t.body.rightMargin   /页面右边距document.body.bottomMargin  /页面下边距document.body.background    /背景图片document.body.appendChild(oTag /动态生成一个HTML对象常用对象事件document.body.onclick="func("          /鼠标指针单击

10、对象是触发document.body.onmouseover="func("      /鼠标指针移到对象时触发document.body.onmouseout="func("       /鼠标指针移出对象时触发 -location-位置子对象document.location.hash      / #号后的部分document.locatio

11、n.host      / 域名+端口号document.location.hostname  / 域名document.location.href      / 完整URLdocument.location.pathname  / 目录部分document.location.port      / 端口号document.lo

12、tocol  / 网络协议(http:document.location.search    / ?号后的部分documeny.location.reload(      /刷新网页document.location.reload(URL   /打开新的网页document.location.assign(URL   /打开新的网页document.location.repla

13、ce(URL  /打开新的网页-selection-选区子对象document.selection-images集合(页面中的图象a通过集合引用document.images             /对应页面上的标签document.images.length      /对应页面上标签的个数document.images0     &

14、#160;    /第1个标签           document.imagesi          /第i-1个标签b通过nane属性直接引用document.images.oImage      /属性c引用图片的src属性document.i

15、mages.oImage.src  /属性.srcd创建一个图象var oImageoImage = new Image(document.images.oImage.src="1.jpg"同时在页面上建立一个标签与之对应就可以显示   var oImage   oImage = new Image(   document.images.oImag

16、e.src="1.jpg"   oImage=document.createElement("IMG"   oImage.src="1.jpg"   document.body.appendChild(oImage-forms集合(页面中的表单a通过集合引用document.forms             

17、0;   /对应页面上的标签 document.forms.length          / 对应页面上 标签的个数 document.forms0              / 第 1 个 标签 document.formsi        &#

18、160;     / 第 i-1 个 标签 document.formsi.length       / 第 i-1 个 中的控件数 document.formsi.elementsj  / 第 i-1 个 中第 j-1 个控件 b通过标签name属性直接引用document.Myform.myctrl         /document.表单名.控件名c访问表单的属

19、性         /对应 属性document.formsi.action       /对应 属性document.formsi.encoding     /对应 属性document.formsi.target       /对应 属性document.formsi.app

20、endChild(oTag /动态插入一个控件-/ 获取文本密码框的值 document.write(document.Myform.oText.value document.write(document.Myform.oPswd.value - 1      2                 function fun(    

21、0;  /遍历checkbox控件的值并判断是否选中       var length       length=document.forms0.chk.length       for(i=0;i   v=document.forms0.chki.value       

22、60;b=document.forms0.chki.checked        if(b          alert(v=v+" 被选中 "        else          alert(v=v+" 未选中 " 

23、60;                          ddd                         - 1 2 3  

24、0; /遍历select控件的option项   var length   length=document.Myform.oSelect.length   for(i=0;i    document.write(document.Myform.oSelecti.value    /遍历option项并且判断某个option是否被选中   for(i=0;i    if

25、(document.Myform.oSelecti.selected!=true    document.write(document.Myform.oSelecti.value    else    document.write(" "+document.Myform.oSelecti.value+""           /根据SelectedIndex打印出选中的opti

26、on   /(0到document.Myform.oSelect.length-1   i=document.Myform.oSelect.selectedIndex   document.write(document.Myform.oSelecti.value   /动态增加select控件的option项   var oOption = document.createElement("OPTION&qu

27、ot;   oOption.text="4"   oOption.value="4"   document.Myform.oSelect.add(oOption;-Text document.all.oDiv                              /引用图层oDiv                document.all.oDiv.style.display=""           

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论