The search property of the Location interface is a search string, also called a query string, that is a string containing a "?" followed by the parameters of the location's URL. If the URL does not have a search query, this property contains an empty string, "". This property can be...
// Assume current page is at https://developer.mozilla.org/en-US/docs/Location/port const result = location.port; // Returns:'' jsCopy to Clipboard // Assume another page is at https://developer.mozilla.org:8888/en-US/docs/Location/port const result = location.port; // Returns:'888...
// Lets imagine an element is in the document const anchor = document.getElementById("myAnchor"); const result = anchor.href; // Returns: 'https://developer.mozilla.org/en-US/Location/href' Specifications Specification HTML # dom-location-href-dev Browser compatibility Help ...
Specifications Specification DOM #interface-document HTML #the-document-object CSSOM View Module #extensions-to-the-document-interface Pointer Lock 2.0 #extensions-to-the-document-interface Selection API #extensions-to-document-interface
The Location.assign() method causes the window to load and display the document at the URL specified.
刷新当前页面,相当于调用了 location.reload() navigation.back() 在导航会话历史中向后移动一页,相当于 history.back() navigation.forward() 在导航会话历史中向前移动一页,相当于 history.forward() navigation.traverseTo(key: string) 在导航会话历史记录中加载特定页面,相当于 history.go(),但区别在于传参不...
Document.location是一个只读属性,返回一个Location对象,包含有文档的 URL 相关的信息,并提供了改变该 URL 和加载其他 URL 的方法。 尽管Document.location是一个只读的Location对象,你也能够赋给它一个DOMString。这意味着你能够赋给 document.location 字符串,大多数情况下像这样使用:document.location = 'https:/...
其中,URL 是相对于 worker 的 location。 如果promise 被拒绝,安装就会失败,这个 worker 不会做任何事情。这也是可以的,因为你可以修复你的代码,在下次注册的时候再次进行尝试。 当安装成功完成之后,service worker 就会激活。在你的 service worker 第一次完成安装/激活时,这并没有什么用。但是当 service worker ...
在 中,Document.referrer 会初始化为父窗口 Window.location 的href。 规范 Specification HTML # dom-document-referrer-dev 浏览器兼容性 Help improve MDN Was this page helpful to you? YesNoLearn how to contribute. This page was last modified on 2022年11月21日 by MDN contributors. View this page ...
const currentHostname = location.hostname; For the URL https://developer.mozilla.org/en-US/docs/Web, currentHostname is also the string "developer.mozilla.org". Other alternatives that provide slightly different information are Location.host, which includes the port, and Window.origin, which ...