JavaScript的BOM_第1页
已阅读5页,还剩9页未读 继续免费阅读

下载本文档

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

文档简介

1、javascript的bomlocation对象location对象提供了与当前窗口中加载的文档有关的信息,还提供了一些导航的功能,它既是window对象的属性,也是document对象的属性。语法:location.href功能:返回当前加载页面的完整url解释:location.href与window.location.href等价语法:location.hash功能:返回url中的hash(号后跟零或多个字符),假如不包含则返回空字符串语法:location.host功能:返回服务器名称和端口号(假如有)语法:locationhostname功能:返回不带端口号的服务器名称。语法:loc

2、ation.pathname功能:返回url中的名目和(或)文件名。语法:location.port功能:返回url中指定的端口号,假如没有,返回空字符串。语法:tocol功能:返回页面用法的协议语法:location.search功能:返回url的查询字符串。这个字符串以问号开始。语法:location.replace(url)功能:重新定向url解释:用法location.replace不会再历时记录中生成新纪录。语法:location.reload()功能:重新加载当前显示的页面。解释:location.reload()有肯从缓冲中加载location.reloa

3、d(true)从服务器重新加载history对象history对象保存了用户在扫瞄器中拜访页面的历史记录语法:history.back()功能:回到历史记录的上一步解释:相当于用法了history.go(-1)语法:location.forward()功能:回到历时记录的下一步解释:相当于用法了history.go(1)语法:history.go(-n)功能:回到历时记录的前n步语法:history.go(n)功能:回到历史记录的后n步navigator对象useragent:用来识别扫瞄器名称,版本,引擎以及操作系统等信息的内容。screen对象语法:screen.availwidth功能:

4、返回可用的屏幕宽度语法:screen.availheight功能:返回可用的屏幕高度location01.html:document.box1height:900px;background:ccc;.box2height:500px;background-color:333;btn.onclick=function()location.hash=&39;box1&39;console.log(location.hash);console.log(location.href);console.log(location.hash);console.log(location.host

5、);console.log(location.hostname);console.log(location.pathname);console.log(location.port);console.log(tocol);console.log(location.search);location02.html:document/*settimeout(function()/location.href=""/window.location=""location.replace("&am

6、p;quot;);,1000);*/document.getelementbyid(&39;btn&39;).onclick=function()location.reload();/location.reload(true);history01.html:documentexample_2.htmlvarbtn1=document.getelementbyid(&39;btn1&39;);varbtn2=document.getelementbyid(&39;btn2&39;);btn1.onclick=function()/history.b

7、ack();history.go(-1);btn2.onclick=function()history.forward()/history.go(1);navigator.html:documentfunctiongetbrowser()varexplorer=navigator.useragent.tolowercase();varbrowser=""if(explorer.indexof("msie")>-1)browser="ie"elseif(explorer.indexof("chrome")>-1)browser=&39;chrome&39;elsebrowser=&39;asdf&39;returnbrowser;varmsg="您用的是"+getbrowser()+&39;扫瞄器&39;console.log(msg);screen.html:documentconsole.log(screen.availw

温馨提示

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

评论

0/150

提交评论