gpt4 book ai didi

javascript - 当 window.document.baseURI 为 "undefined"时?

转载 作者:行者123 更新时间:2023-12-01 01:42:46 24 4
gpt4 key购买 nike

我总是在开发者工具中看到两个实体(baseURI 和 URL)显示相同的 URL,大多数时候都显示在地址栏中。这些是 window.document 对象的属性。那么什么时候基础URI属性是“未定义”的呢?

最佳答案

他们做不同的事情。

对于地址栏中的内容,您通常需要 window.location.href .

baseURI property另一方面,节点数用作解析该节点内相对 URL 的基础,例如 src图像或 href的一个链接。 baseURI可以通过添加 <base> element 来更改.

我没有发现 baseURI 的情况是 undefined 。即使在通过 document.implementation.createDocument 创建的文档中,它只是继承自当前的 document 。添加一个空<base>元素没有影响。分配undefinedbaseURI根本就被忽略了。

关于javascript - 当 window.document.baseURI 为 "undefined"时?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52269994/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com