javascript复习5:高级对象

本文介绍了如何使用JavaScript实现网页的前进、后退、刷新、加载新文档等功能,并展示了如何获取当前屏幕尺寸、浏览器信息及Cookies状态等。通过具体代码示例,读者可以了解这些功能的具体实现方式。
<input type="button" value="Back" onclick="goBack()" /><br />
<input type="button" value="Forward" onclick="goForward()" /><br />
<input type="button" value="Back5" onclick="goBack5()" /><br />
<input type="button" value="Load new document" onclick="newDoc()" /><br />
<input type="button" value="Reload page" onclick="reloadPage()" /><br />
<input type="button" value="Replace document" onclick="replaceDoc()" /><br />

history

function goBack()
  {
  window.history.back()
  }

function goForward()
  {
  window.history.forward()
  }

function goBack5()
  {
  window.history.go(-5)
  }
location

document.write(location.href);

function newDoc()
  {
  window.location.assign("http://127.0.0.1/js1")
  }

function reloadPage()
  {
  window.location.reload()
  }

function replaceDoc()
  {
  window.location.replace("http://127.0.0.1/js1")
  }
screen

document.write("<p>Width: ")
document.write(screen.width + "</p>")
document.write("<p>Height: ")
document.write(screen.height + "</p>")
document.write("<p>Pixel Depth: ")
document.write(screen.pixelDepth + "</p>")

navigator
document.write("<p>浏览器:")
document.write(navigator.appName + "</p>")

document.write("<p>浏览器版本:")
document.write(navigator.appVersion + "</p>")

document.write("<p>代码:")
document.write(navigator.appCodeName + "</p>")

document.write("<p>平台:")
document.write(navigator.platform + "</p>")

document.write("<p>Cookies 启用:")
document.write(navigator.cookieEnabled + "</p>")

document.write("<p>浏览器的用户代理报头:")
document.write(navigator.userAgent + "</p>")

document.write("<p>是否在线:")
document.write(navigator.onLine + "</p>")

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值