document.domian document.URL document.baseURI(Node.baseURI) document.documentURI location.href

document.domian document.URL document.baseURI(Node.baseURI) document.documentURI location.href
document.domain location.host location.origin

  • document.domian
  • document.URL
  • document.baseURI(Node.baseURI)
  • document.documentURI
  • location.href
  • document.domain
  • location.host
  • location.origin

在这里插入图片描述
网络页面(本页)的location:host,hostname,href,origin,pathname

在这里插入图片描述

本地文件页面的location:host,hostname,href,origin,pathname
在这里插入图片描述

网络的document.domian
在这里插入图片描述
本地的document.domian是空字符串
在这里插入图片描述

domian域名 hostname主机名

网络
在这里插入图片描述

本地文件
在这里插入图片描述

host 和 hostname 的区别:

host带port(80不显示), hostname不带

location.hostname 和 document.domain 的区别

在这里插入图片描述

document.URL , document.documentURI , location.href , node.baseURI
document.URL

返回当前文档的 URL 地址

该属性的值和DOM Level 0 中的document.location.href 属性的值是相等的。然而 document.location.href 是可写的,document.URL 是只读的。

document.documentURI 也返回与该属性相同的值,不过它在非 HTML 文档中也可以使用。

document.documentURI

Document 接口的属性 documentURI 以字符串的形式返回文档的位置(location)。在最初的 DOM3 定义中,这个属性是可读/写的。在现代的 DOM 标准(DOM4)中,它是只读的。
HTML 文档有一个 document.URL 属性返回同样的值。但是不像 URL,documentURI 适用于所有类型的文档。

location.href

Location 接口的 href 属性是一个字符串化转换器 (stringifier), 返回一个包含了完整 URL 的 USVString 值,且允许 href 的更新。

document.location.href和document.location.replace都可以进入指定页面
document.location.href切换后,回退按钮有效
document.location.replace切换后,回退无效

Node.baseURI(document.baseURI)

Node.baseURI 是只读属性,返回一个节点的绝对基址 URL。

当浏览器要获取绝对 URL 时,就需要用基 URL 去解析相对 URL。例如,解析 HTML 元素的 src 属性时,或者 处理 XML xlink:href 属性时—。

一般情况下,基 URL 是 document 的 location,但是它受诸多方面因素的影响,例如 HTML 的 元素和 XML xml:base (en-US) 属性。

document.URL 和 location.href 的区别

document.URL只读 , location.href可以再赋值
document.URL属性的值和DOM Level 0 中的document.location.href 属性的值是相等的。然而 document.location.href 是可写的,document.URL 是只读的。

document.URL 属于比较老的 api, 作为代替应该尽量使用 window.location.href 而非 document.URL.

document.URL 和 document.baseURI 的区别

document.URL 是document专有的
document.baseURI 是 node.baseURI … head,body等元素节点都有baseURI属性
一般来说 document.URL===document.baseURI

<base>:文档根 URL 元素
HTML <base> 元素 指定用于一个文档中包含的所有相对 URL 的根 URL。一份中只能有一个 <base> 元素。

一个文档的基本 URL,可以通过使用 document.baseURI (en-US) 的 JS 脚本查询。如果文档不包含 <base> 元素,baseURI 默认为 document.location.href




url的结构

在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

kfepiza

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值