https://developer.mozilla.org/en-US/docs/Web/API/Location
Vegeu les diferents parts d'una URL que podem obtenir amb Javascript i Window.location:
És similar a canviar el href de window.location però en una funció amb paràmetres extres per tenir un major control de la nova finestra que s'obre:
https://developer.mozilla.org/en-US/docs/Web/API/Window/open
Per exemple:
window.location.href = 'http://www.google.com'; //Will take you to Google.
Es pot fer amb:
window.open('http://www.google.com'); //This will open Google in a new window.
Exemple d'opcions:
var windowObjectReference;
function openRequestedPopup() { windowObjectReference = window.open( "http://www.domainname.ext/path/ImageFile.png", "DescriptiveWindowName", "resizable,scrollbars,status" ); }
Permet canviar la URL, és a dir realitzar una redirecció URL. Vegeu https://developer.mozilla.org/en-US/docs/Web/API/Location
https://developer.mozilla.org/en-US/docs/Web/API/Window/location
Els més simples i rellevants:
Example #1: Navigate to a new page:
location.assign("http://www.mozilla.org"); // or location = "http://www.mozilla.org";
Oco amb CORS qe pot previndre que això no funcioni.
Example #2: Force reloading the current page from the server
location.reload(true);
Example #3
Consider the following example, which will reload the page by using the replace() method to insert the value of location.pathname into the hash:
function reloadPageWithHash() { var initialPage = location.pathname; location.replace('http://example.com/#' + initialPage); }
Vegeu OAuth_hybrid_apps#Forward_page/Pàgina de Forward
<html> <head> <script> function newDoc() { window.location.assign("https://www.w3schools.com") } </script> </head> <body> <input type="button" value="Load new document" onclick="newDoc()"> </body> </html>
https://developer.mozilla.org/en-US/docs/Web/API/Location