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

JavaScript学习笔记(十一)_基础知识

document对象

下表列出了BOMdocument对象的一些通用属性:

alinkColor

激活的链接的颜色,如定义的*

bgColor

页面的背景颜色,如定义的*

fgColor

页面的文本颜色,如定义的*

lastModified

最后修改页面的日期,是字符串

linkColor

链接的颜色,如定义的*

referrer

浏览器历史中后退一个位置的URL

title

<FONT face=宋体>标签中显示的文本</FONT></P></TD></TR> <TR> <TD vAlign=top width=151> <P>URL</P></TD> <TD vAlign=top width=439> <P><FONT face=宋体>当前载入的页面的</FONT>URL</P></TD></TR> <TR> <TD vAlign=top width=151> <P>vlinkColor</P></TD> <TD vAlign=top width=439> <P><FONT face=宋体>访问过的链接的颜色,如</FONT><body vlink="color"><FONT face=宋体>定义的</FONT><SUP>*</SUP></P></TD></TR></TBODY></TABLE></DIV> <P>* <FONT face=宋体>反对使用这些属性,因为它们引用了</FONT><body/><FONT face=宋体>标签中的旧</FONT>HTML<FONT face=宋体>特性。应该用样式表脚本代替它们。</FONT></P> <P> </P> <P>document<FONT face=宋体>对象也有许多集合,提供对载入的页面各个部分的访问。下表列出了这些集合:</FONT></P> <P> </P> <DIV align=center> <TABLE cellSpacing=0 cellPadding=0 width=556 border=0> <TBODY> <TR> <TD vAlign=top width=180> <P><FONT face=宋体>集</FONT> <FONT face=宋体>合</FONT></P></TD> <TD vAlign=top width=376> <P><FONT face=宋体>说</FONT> <FONT face=宋体>明</FONT></P></TD></TR> <TR> <TD vAlign=top width=180> <P>anchors</P></TD> <TD vAlign=top width=376> <P><FONT face=宋体>页面中所有锚的集合</FONT></P></TD></TR> <TR> <TD vAlign=top width=180> <P>applets</P></TD> <TD vAlign=top width=376> <P><FONT face=宋体>页面中所有</FONT>applet<FONT face=宋体>的集合</FONT></P></TD></TR> <TR> <TD vAlign=top width=180> <P>embeds</P></TD> <TD vAlign=top width=376> <P><FONT face=宋体>页面中所有嵌入式对象的集合(由</FONT><embed/><FONT face=宋体>标签表示)</FONT></P></TD></TR> <TR> <TD vAlign=top width=180> <P>forms</P></TD> <TD vAlign=top width=376> <P><FONT face=宋体>页面中所有表单的集合</FONT></P></TD></TR> <TR> <TD vAlign=top width=180> <P>images</P></TD> <TD vAlign=top width=376> <P><FONT face=宋体>页面中所有图像的集合</FONT></P></TD></TR> <TR> <TD vAlign=top width=180> <P>links</P></TD> <TD vAlign=top width=376> <P><FONT face=宋体>页面中所有链接的集合</FONT></P></TD></TR></TBODY></TABLE></DIV> <P><FONT face=宋体>与</FONT>window.frame<FONT face=宋体>集合相似,可用数字或名字引用</FONT>document<FONT face=宋体>对象的每个集合,也就是说可用</FONT>document.images[0]<FONT face=宋体>或</FONT>document.images["<FONT face=宋体>图片的</FONT>name"]<FONT face=宋体>访问图像。</FONT></P> <P><FONT face=宋体></FONT> </P> <H1>location对象</H1> <P><FONT face=宋体>location对象表示载入窗口的URL,此外它还可以解析URL。</FONT></P> <P><FONT face=宋体><STRONG>hash</STRONG>——如果URL包含#,该方法将返回该符号之后的内容(例如,http://www.somewhere.com/index#selection1的hash等于"#selection1")。</FONT></P> <P><FONT face=宋体><STRONG>host</STRONG>——服务器的名字(如www.wrox.com)。</FONT></P> <P><FONT face=宋体><STRONG>hostname</STRONG>——通常等于host,有时会省略前面的www。</FONT></P> <P><FONT face=宋体><STRONG>href</STRONG>——当前载入的页面的完整URL。</FONT></P> <P><FONT face=宋体><STRONG>pathname</STRONG>——URL中<STRONG>主机名后的部分</STRONG>。例如,http://www.somewhere.com/pictures/index.htm的pathname是"/pictures/index.htm"。</FONT></P> <P><FONT face=宋体><STRONG>port</STRONG>——URL中声明的请求的端口。默认情况下,大多数URL没有端口信息,所以该属性通常是空白的。像http://www.somewhere.com:8080/index.htm这样的URL的port属性等于8080。</FONT></P> <P><FONT face=宋体><STRONG>protocol</STRONG>——URL中使用的协议,即双斜杠(//)之前的部分。例如,http://www.somewhere.com中的protocol属性等于http:,ftp://www.somewhere.com的protocol属性等于ftp:。</FONT></P> <P><FONT face=宋体><STRONG>search</STRONG>——执行GET请求的URL中的问号(?)后的部分,又称为查询字符串。例如,http://www.somewhere.com/abc.htm?term=javascript中的search属性等于?term=javascript</FONT></P> <P><FONT face=宋体></FONT> </P> <P><FONT face=宋体>跳转到一个页面,但是不想从浏览器历史中访问,即不能后退回来,可以使用方法<STRONG>location.replace</STRONG>(</FONT>"http://www.baidu.com"<FONT face=宋体>)方法。</FONT></P> <P><FONT face=宋体></FONT> </P> <H1>navigator对象</H1> <P><FONT face=宋体>检测<STRONG>浏览器</STRONG>的版本、所支持的MIME类型、已安装的外挂程序(plug-in)。该对象包含两个子对象:外挂对象、MIME类型对象。</FONT></P> <TABLE cellSpacing=1 cellPadding=0 width=450 border=1> <TBODY> <TR> <TD width=160> <P align=center><STRONG><FONT face=宋体>appCodeName</FONT></STRONG></P></TD> <TD> <P><FONT face=宋体>代码</FONT></P></TD></TR> <TR> <TD> <P align=center><STRONG><FONT face=宋体>appName</FONT></STRONG></P></TD> <TD> <P><FONT face=宋体>名称</FONT></P></TD></TR> <TR> <TD> <P align=center><STRONG><FONT face=宋体>appVersion</FONT></STRONG></P></TD> <TD> <P><FONT face=宋体>版本</FONT></P></TD></TR> <TR> <TD> <P align=center><STRONG><FONT face=宋体>language</FONT></STRONG></P></TD> <TD> <P><FONT face=宋体>语言</FONT></P></TD></TR> <TR> <TD> <P align=center><STRONG><FONT face=宋体>mimeType</FONT></STRONG></P></TD> <TD> <P><FONT face=宋体>以数组表示所支持的MIME类型</FONT></P></TD></TR> <TR> <TD> <P align=center><STRONG><FONT face=宋体>platform</FONT></STRONG></P></TD> <TD> <P><FONT face=宋体>编译浏览器的机器类型</FONT></P></TD></TR> <TR> <TD> <P align=center><STRONG><FONT face=宋体>plugins</FONT></STRONG></P></TD> <TD> <P><FONT face=宋体>以数组表示已安装的外挂程序</FONT></P></TD></TR> <TR> <TD> <P align=center><STRONG><FONT face=宋体>userAgent</FONT></STRONG></P></TD> <TD> <P><FONT face=宋体>用户代理程序的表头</FONT></P></TD></TR></TBODY></TABLE> <P><FONT face=宋体></FONT> </P> <H1>screen对象</H1> <P><FONT face=宋体>screen对象包含了<STRONG>屏幕</STRONG>信息,通常包含下列属性(不过,许多浏览器都加入了自己的属性):</FONT></P> <P><FONT face=宋体><STRONG>height</STRONG>——屏幕的高度,以像素计。</FONT></P> <P><FONT face=宋体><STRONG>width</STRONG>——屏幕的宽度,以像素计。</FONT></P> <P><FONT face=宋体><STRONG>availHeight</STRONG>——窗口可以使用的屏幕的高度(以像素计),减去了任务栏的宽,随用户任务栏而变,不会随窗口而改变,其中包括操作系统元素(如Windows工具栏)需要的空间。</FONT></P> <P><FONT face=宋体><STRONG>availWidth</STRONG>——窗口可以使用的屏幕的宽度(以像素计),减去了任务栏的高,随用户任务栏而变。</FONT></P> <P><FONT face=宋体><STRONG>colorDepth</STRONG>——用户屏幕的颜色深度,以每像素的位数计。实际上就是表示颜色的位数。大多数系统采用32位。</FONT></P> <P><FONT face=宋体></FONT> </P> <P><FONT face=宋体>确定新窗口的大小时,availHeight和availWidth属性非常有用。例如,可以使用下面的代码填充用户的屏幕:</FONT></P> <P><FONT face=宋体>moveTo(0,0);</FONT></P> <P><FONT face=宋体>resizeTo(screen.availWidth,screen,availHeight);</FONT> </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:'JavaScript学习笔记(十一)_基础知识代码块', 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>