前端面经 实用的BOM属性对象方法

前端面经 实用的BOM属性对象方法

location 对象

  1. location.href
    返回或用于设置当前文档的url —— https://developer.mozilla.org/zh-CN/docs/Web/API/Location

  2. location.search
    返回URL 中的查询字符串部分

    例如:当前的url为https://developer.mozilla.org/zh-CN/docs/Web/API/Location?a=1&b=2
    location.search'?a=1&b=2'

  3. location.hash
    返回URL#后面的内容,如果没有#,返回空

    例如:当前的url为https://developer.mozilla.org/zh-CN/docs/Web/API/Location#search-results-close-container
    location.hash#search-results-close-container

  4. loaction.host
    返回URL 中的域名部分

    例如:当前的url为https://developer.mozilla.org/zh-CN/docs/Web/API/Location
    location.hostdeveloper.mozilla.org

  5. location.pathname
    返回URL 的域名后的部分

    例如:当前的url为https://developer.mozilla.org/zh-CN/docs/Web/API/Location
    location.pathname'/zh-CN/docs/Web/API/Location'

  6. loaction.port
    返回URL 中的端口部分

    例如:当前的url为https://developer.mozilla.org/zh-CN/docs/Web/API/Location
    location.port''

  7. location.protocol
    返回URL 中的协议部分

    返回http:https:

  8. location.assign(url)
    设置当前文档的URL

  9. location.replace(url)
    用给定的 URL 替换掉当前的资源。与 assign() 方法不同的是用 replace()替换的新页面不会被保存在会话的历史 History中,这意味着用户将不能用后退按钮转到该页面

  10. location.reload()
    重载当前页

history对象

  1. history.go(num)
    前进或后退指定页数
  2. history.back()
    后退一页
  3. history.forward
    前进一页

Navigator

  1. navigator.userAgent
    返回用户代理头的字符串(就是包含浏览器版本信息等的字符串)
  2. navigator.cookieEnabled
    返回浏览器是否支持(启用)cookie
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值