This code seems to behave differently in every browser I tested, and behavior in WebKit has been changing between versions. What should we be doing? <html><head><title>pressed</title> <script type=text/javascript> function ev_onclick() { document.write("Generated from script 1"); } function ev_onsubmit() { document.write("Generated from script 2"); } </script> <body> <form onsubmit=ev_onsubmit() action="" method=post><input onclick=ev_onclick() type=submit value="Submit Query"> </form><br> </body></html>
(In reply to comment #0) > This code seems to behave differently in every browser I tested, and behavior > in WebKit has been changing between versions. What should we be doing? What does each browser do that you've tested?
Firefox displays the submit handler and loads forever Opera, Konqueror display the submit handler and stop Safari 2 goes blank WebKit recent trunk goes back to the form
The click ev_onevent() function should fire first when you click the button. It replaces the document with a new document, and that ends that. So you should end up with a document that just says "Generated from script 1". Ok so I wrote that based on just my knowledge of HTML5. Now for reality. I tested IE7 and Mozilla trunk, and luckily for my credibility, both do exactly what I just described. Score!