From an admin page if the user is valid then the browser should go to another page.
When a user enters his user name and password, then clicks the OK button then another page is displayed and the login page is automatically closed.
How can I do this with JavaScript?
There are two ways to pass variables between web pages. The first method is to use sessionStorage, or localStorage. The second method is to use a query string with the URL.
How to Redirect to Another Page in HTML. To redirect one HTML page to another page, you need to add a <meta> tag inside the <head> section of the old HTML page. The <head> section of an HTML document contains metadata that is useful for the browser, but invisible to users viewing the page.
Approach: To redirect from an HTML page to another page, you can use the <meta> tag by specifying the particular link in the URL attribute. It is the client-side redirection, the browsers request the server to provide another page.
Approach: We can use window. location property inside the script tag to forcefully load another page in Javascript. It is a reference to a Location object that is it represents the current location of the document. We can change the URL of a window by accessing it.
To simply redirect a browser using javascript:
window.location.href = "http://example.com/new_url";
To redirect AND submit a form (i.e. login details), requires no javascript:
<form action="/new_url" method="POST"> <input name="username"> <input type="password" name="password"> <button type="submit">Submit</button> </form>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With