BOM 浏览器对象

2018-07-17  本文已影响0人  丶Romantic

<script type="text/javascript">
//navigator对象
console.log(navigator.userAgent)//浏览器信息
console.log(navigator.plugins)//返回浏览器所安装的插件
console.log(navigator.platform)
console.log(navigator.onLine)//能否上网 布尔值
console.log(navigator.language)//返回浏览器的首选语言
console.log(navigator.languages)//返回浏览器可接受的语言。

    //history对象
    console.log(window.history)//当前窗口的浏览历史
    console.log(window.history.length)

// console.log(history.back())//后退
// console.log(history.forward())//前进
// console.log(history.go(-2))//跳转到指定页面
// console.log(history.go(0))//相当于刷新页面

    //location对象
    console.log(window.location)//有关当前 URL 的信息
    console.log(location.hash)//返回或设置当前url的片段标识符, 表示资源内的某一位置,在html文档中浏览器会寻找namr属性为指定值的a标签 找到后滚动页面到盖位置进行展示
    console.log(location.protocol)//返回当前的url协议
     console.log(location.href)//返回或设置当前完整的url  也可放在点击事件中 更改location.href="网址"
    console.log(location.hostname)//返回或设置当前完整的服务器地址
    console.log(location.host)//返回或设置当前完整的服务器地址和端口号
    console.log(location.port)//只返回url的端口号
    console.log(location.pathname)//返回或者设置当前url路径部分
     console.log(location.search)//返回或设置当前URL查询字符串
    console.log(location.hash)//返回或设置当前URL的片段标识符
    console.log(location.reload())//刷新页面
    console.log(location.assign("网址"))//加载新页面
    console.log(location.replace(""))//替换新页面  不会在历史记录中保留信息
    console.log(encodeURI("www.---"))
    console.log(decodeURI("www.---"))
上一篇 下一篇

猜你喜欢

热点阅读