输入banner图图片脚本导航/分类

超清晰的document对象详解_基础知识

document 文挡对象 - JavaScript脚本语言描述
---------------------------------------------------------------------
注:页面上元素name属性和JavaScript引用的名称必须一致包括大小写
否则会提示你一个错误信息 "引用的元素为空或者不是对象"
---------------------------------------------------------------------

对象属性
document.title //设置文档标题等价于HTML的标签 <BR>document.bgColor //设置页面背景色 <BR>document.fgColor //设置前景色(文本颜色) <BR>document.linkColor //未点击过的链接颜色 <BR>document.alinkColor //激活链接(焦点在此链接上)的颜色 <BR>document.vlinkColor //已点击过的链接颜色 <BR>document.URL //设置URL属性从而在同一窗口打开另一网页 <BR>document.fileCreatedDate //文件建立日期,只读属性 <BR>document.fileModifiedDate //文件修改日期,只读属性 <BR>document.fileSize //文件大小,只读属性 <BR>document.cookie //设置和读出cookie <BR>document.charset //设置字符集 简体中文:gb2312 <BR>--------------------------------------------------------------------- <BR>对象方法 <BR>document.write() //动态向页面写入内容 <BR>document.createElement(Tag) //创建一个html标签对象 <BR>document.getElementById(ID) //获得指定ID值的对象 <BR>document.getElementsByName(Name) //获得指定Name值的对象 <BR>--------------------------------------------------------------------- <br><br>images集合(页面中的图象) <br><br>a)通过集合引用 <BR>document.images //对应页面上的<img>标签 <BR>document.images.length //对应页面上<img>标签的个数 <BR>document.images[0] //第1个<img>标签 <BR>document.images[i] //第i-1个<img>标签 <br><br>b)通过nane属性直接引用 <BR><img name="oImage"> <BR>document.images.oImage //document.images.name属性 <br><br>c)引用图片的src属性 <BR>document.images.oImage.src //document.images.name属性.src <br><br>d)创建一个图象 <BR>var oImage <BR>oImage = new Image() <BR>document.images.oImage.src="http://img.gxlcms.com/http://img.gxlcms.com//1.jpg" <BR>同时在页面上建立一个<img>标签与之对应就可以显示 <br><br><html> <BR><img name=oImage> <BR><script language="javascript"> <BR> var oImage <BR> oImage = new Image() <BR> document.images.oImage.src="http://img.gxlcms.com/http://img.gxlcms.com//1.jpg" <BR></ script> <BR></html> <br><br>---------------------------------------------------------------------- <br><br>forms集合(页面中的表单) <br><br>a)通过集合引用 <BR>document.forms //对应页面上的 <BR>document.Myform.myctrl //document.表单名.控件名 <br><br>----------------------------------------------------------------------- <BR><html> <BR><!--Text控件相关Script--> <BR> <br><br><script language="javascript"> <BR> //遍历select控件的option项 <BR> var length <BR> length=document.Myform.oSelect.length <BR> for(i=0;i<length;i++) <BR> document.write(document.Myform.oSelect[i].value) <BR></ script> <br><br><script language="javascript"> <BR> //遍历option项并且判断某个option是否被选中 <BR> for(i=0;i<document.Myform.oSelect.length;i++){ <BR> if(document.Myform.oSelect[i].selected!=true) <BR> document.write(document.Myform.oSelect[i].value) <BR> else <BR> document.write("<font color=red>"+document.Myform.oSelect[i].value+"</font>") <BR> } <BR></ script> <br><br><script language="javascript"> <BR> //根据SelectedIndex打印出选中的option <BR> //(0到document.Myform.oSelect.length-1) <BR> i=document.Myform.oSelect.selectedIndex <BR> document.write(document.Myform.oSelect[i].value) <BR></ script> <br><br><script language="javascript"> <BR> //动态增加select控件的option项 <BR> var oOption = document.createElement("OPTION"); <BR> oOption.text="4"; <BR> oOption.value="4"; <BR> document.Myform.oSelect.add(oOption); <BR></ script> <BR><html> <BR>----------------------------------------------------------------------- <BR><Div id="oDiv">Text</Div> <BR>document.all.oDiv //引用图层oDiv <BR>document.all.oDiv.style <BR>document.all.oDiv.style.display="" //图层设置为可视 <BR>document.all.oDiv.style.display="none" //图层设置为隐藏 <BR>/*document.all表示document中所有对象的集合 <BR>只有ie支持此属性,因此也用来判断浏览器的种类*/ </div> </div> <script type="text/javascript" src="/layui/layui.js"></script> <script> layui.use('code', function(){ layui.code({ elem: 'pre', //默认值为.layui-code about:false, title:'超清晰的document对象详解_基础知识代码块', encode: true //是否转义html标签。默认不开启 }); }); </script> <footer class="comm-footer"> <ul class="channels"> <li> <a target="_top" href="/system/">操作系统</a> </li><li> <a target="_top" href="/down/">程序下载</a> </li><li> <a target="_top" href="/jquery/">jquery插件库</a> </li><li> <a target="_top" href="/jiaoben/">编程</a> </li><li> <a target="_top" href="/db/">数据库</a> </li><li> <a target="_top" href="/tools/">在线工具</a> </li><li> <a target="_top" href="/framebook/">框架书籍</a> </li><li> <a target="_top" href="/xitongjiaocheng/">系统教程</a> </li><li> <a target="_top" href="/ruanjianxiazai/">软件下载</a> </li> </ul> <ul class="versions"> <li> <a href="https://m.gxlcms.com" class="active">触屏版</a> </li> <li> <a href="https://www.gxlcms.com" target="_top">电脑版</a> </li> </ul> <p><a href="https://beian.miit.gov.cn/" target="_blank" style="color:#ffffff"></a><script> var _hmt = _hmt || []; (function() { var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?6c9b8cea1903c9f813f150c04aeebc3c"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script></p> </footer> </body> </html>