Page 1 of 1

[Javascript] URL Redirection

PostPosted: Sun Oct 08, 2017 2:13 pm
by admin
Select what is most suitable to your needs:

// Sets the new location of the current window.
Code: Select all
window.location = "https://www.example.com";


// Sets the new href (URL) for the current window.
Code: Select all
window.location.href = "https://www.example.com";


// Assigns a new URL to the current window.
Code: Select all
window.location.assign("https://www.example.com");


// Replaces the location of the current window with the new one.
Code: Select all
window.location.replace("https://www.example.com");


// Sets the location of the current window itself.
Code: Select all
self.location = "https://www.example.com";


// Sets the location of the topmost window of the current window.
Code: Select all
top.location = "https://www.example.com";


Use it like in this example:

Code: Select all
<SCRIPT LANGUAGE="JavaScript">
// Sets the new location of the current window.
window.location = "http://example.com";
</SCRIPT>


For in-depth explanation and more options, go to:
https://appendto.com/2016/04/javascript ... avascript/