In my HTML file i have a form that has the following submit button:
<button id="submit" >Submit</button>
In my Javascript file i did the following :
window.onload=function(){
document.getElementById("submit").onclick = form_action;
}
function form_action()
{
window.location.href="www.google.com";
}
So, the submit button redirects to another webpage. ( I read some data from a form, but that doesn't matter right now, and after that i redirect to another page). The thing is, the redirect does not happen at all!
The only way i was able to make it work was by adding : alert(location.href)
after window.location.href="www.google.com";
. My guess is that this forces the update of the window?
How do i work around this problem? Why does this occur? Can someone offer some insight? I want to solve it purely by using Javascript.
I do not wish to modify my HTML file nor use Jquery.