The Location assign() method is used for loading a new document. It can also be used for loading a new document but the difference between these two methods is that the replace() method removes the URL of the current document from the document history and therefore it is not possible to navigate back to the original document using the “back” button.
- URL: It is a mandatory parameter which specifies the URL of the page to navigate to.
Below program illustrates the Location assign() Method :
Loading a new document.
After clicking the button
Note: Above program would not work for all links as cross framing is not allowed in many cases, try it by assigning link “https://ide.geeksforgeeks.org/”.
Supported Web Browsers
- Google Chrome
- Internet Explorer
- HTML | DOM Location replace() Method
- HTML | DOM Location reload() Method
- HTML | DOM Location pathname Property
- HTML | DOM Location hash Property
- HTML | DOM Location href Property
- HTML | DOM KeyboardEvent location Property
- HTML | DOM Location hostname Property
- HTML | DOM Location port Property
- HTML | DOM Location host Property
- HTML | DOM Location protocol Property
- HTML | DOM Location Search Property
- HTML | DOM Location origin Property
- HTTP headers | Location
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.