Reputation: 55
I know this has been asked before both on here and elsewhere, but everything I've tried and read is still failing for me.
I have (so far) tried the following inside a method I am successfully calling:
window.location.href = "http://www.google.co.uk";
window.location.replace = "http://www.google.co.uk";
window.location = "http://www.google.co.uk";
window.navigate = "http://www.google.co.uk";
location.replace("http://www.google.co.uk");
window.location.assign("http://www.google.co.uk");
self.location = "http://www.google.co.uk";
top.location = "http://www.google.co.uk";
location.assign("http://www.google.co.uk");
This is inside a method I am calling from a button:
<button class="btn btn-default" id="SaveAndExit" onclick="saveAndExit();">GO TO GOOGLE</button>
This should be straightforward for something I've broken down so simple, but my screen just refreshes without navigating to the URL I specify.
What can't I see please?!
Upvotes: 1
Views: 66
Reputation: 4853
You should have an <input type="button">
instead of a button
component.
So your button should look like:
<input type="button" class="btn btn-default" id="SaveAndExit" onclick="saveAndExit();">GO TO GOOGLE</button>
Upvotes: 2
Reputation: 16041
The default type of a HTML button
is submit
, in this case onclick
does not run, use
<button type="button" class="btn btn-default" id="saveAndExit" onclick="saveAndExit()">
Upvotes: 3