I have this page, on which I have a button. The button does nothing more than window.close(). But the problem is that the page contains a form onsubmit script, which checks to see if the sum of all dropdownlists equals 10.
So when I implemented the button to immediately close the window, it would trigger the submit on the form. To solve this, you have to write window.close();return false; instead of just window.close();.
You would think that when window.close() executes, the form won’t do a submit… I didn’t think this was obvious, that’s why I made a post about it. Hope it’s useful to someone.
Technorati Tags: javascript, onclick, window.close, onsubmit









What is really happening here? ,
The problem is that when I press the button that closes the window, I do not want any submit to happen. In order for this to work, you have to include “return false;” after your “window.close;”. Otherwise, the submit form would trigger, which is a behaviour I do not want for this certain case.