javascript高级程序设计第8章

window对象

Window 对象表示浏览器中打开的窗口 全局作用域

  • 窗口关系以及框架 window.fames
  • 窗口位置 window.screen window.screenLeft window.screenTop
  • 窗口大小 window.innerWidth window.innerHeight
  • 导航和打开窗口 window.open

 

window.open("http://www.runoob.com","_blank","toolbar=yes, location=yes, directories=no, status=no, menubar=yes, scrollbars=yes, resizable=no, copyhistory=yes, width=400, height=400");
url,target,feture

  • setTimeout
  • setInterval
  • 系统对话框 alert() confirm() prompt()

 

location对象 最有用的BOM对象

常用于获取url参数
function getUrlParam(name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
var r = decodeURI(window.location.search).substr(1).match(reg); //匹配目标参数
if (r != null) return unescape(r[2]); //返回参数值
}

navigator对象 用于检测浏览器类型

screen对象

history对象 不常用对象

客户端存储数据

  • localStorage 没有时间限制

localStorage.setItem() 存储
localStorage.getItem() 取值
localStorage.clear() 清空

  • sessionStorage 浏览器关闭之后 数据会被删除

猜你喜欢

转载自www.cnblogs.com/joyce123/p/10848041.html