Net-informations.com
SiteMap  | About    

Redirect to another page on load

You can redirect a web page via JavaScript using a number of methods. If you want a cross-browser compliant JavaScript redirect script, better to use the following scripts.

example

You can use window.location object to load another page in JavaScript.

example

Difference between window.location and location.href

  1. window.location is an object that holds all the information about the current document location (host, href, port, protocol etc.).

  2. location.href is shorthand for window.location.href (you call location from global object - window, so this is window.location.href), and this is only a string with the full URL of the current website.

Other methods of JavaScript redirection

Assigns a new URL to the current window.

Replaces the location of the current window with the new one.

Sets the location of the current window itself.

Sets the location of the topmost window of the current window.









net-informations.com (C) 2018    Founded by raps mk
All Rights Reserved. All other trademarks are property of their respective owners.