Reputation: 1427
I have a button which calls a Javascript function when it is pressed, that function is just redirecting to another page, it looks like this:
<input type="submit" value="Submit" id="button1" name="button1" onclick="myFunction()" />
And the function looks like this:
function myFunction() {
window.location.href = "page2.html";
}
The function is executed but the redirection does not work, it remains on the same page, but if I set a breakpoint on the function and execute it line by line using the Browser dev tools it successfully redirects to the other page.
---------EDIT---------
It works only using the Firefox dev tools, if I set the breakpoint on Chrome it still does not works.
Upvotes: 0
Views: 66
Reputation: 340
Try setting the href to just
location.href = "page2.html".
As IE and Firefox are concerned, "/path" is invalid.
"Sorry, cannot leave comment yet"
Upvotes: 1
Reputation: 1
It's the nature of your input type. Change the type to "button" and you'll be good to go!
Upvotes: 0