consider we are // when we run this line location.replace("htts://") // it will replace the current page and redirect to medium page Replaces the current resource with the one at the provided URL. Then it loads the page from the server, instead of loading from the browser cache. It has an optional parameter forceReload, which defaults to false when forceReload is true. The Location.reload() method reloads the current URL, like the Refresh button. Loads the resource at the URL provided in the parameter. consider we are at page : location.origin // This will be useful when we have links inside the same page.Įxample from MDN Web Docs: Examples var anchor = document.getElementById("myAnchor") console.log(anchor.hash) // Returns '#Examples' 9. HashĬontains string of '#' followed by the fragment identifier of the URL. I am on page arch // ?q=javascriptjeep 8. PathnameĬontains the path after the hostname. var anchor = document.createElement("a") anchor.href = " anchor.port // "4097" 6. If the URL does not contain an explicit port number, it will be set to ''. location.host // // with port number var anchor = document.createElement("a") anchor.href = " anchor.host // "medium:4097" 4. ProtocolĬontains the protocol ( http,https.) of the page. Otherwise, it makes the request on the same page. When we assign a new value to the property, it will redirect the url value set to the property. location.href // current page url addresss
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |