I have a link like this:
<a href="www.example.com">
I would like to simulate the clicking of this link within javascript with a function that is called with the left arrow but I am not sure how to do it.
Now I have this:
$(window).keypress(function (e)
{
if (e.keyCode == 37)
{
// position 1
}
});
But I am not sure how to change the page to the link "www.example.com" from within javascript at position 1. Can someone help me with this.
JavaScript window. To navigate to a new URL, use the location object from the Browser's History API. The session history lets you reassign the location object to a new URL or use the href property on that same object. The syntax for this approach is: window.
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.
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.
You could use the following to perform a redirect:
window.location.href = 'www.example.com';
You could set window.location
to the url you want the page to load, like:
window.location = "www.example.com"
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