javascript, Google Chrome treats alert call from input and html buttons differently -


i created form processed javascript (no submit) , found google chrome erasing inputs when popped alert. after experimenting, found chrome behaves differently depending on whether javascript alert called button element or input element. in particular, html button causes text in input box deleted when click ok. not happen in ie. have not tried in other browsers. not happen input element, , not happen button element if outside form.

has else noticed this, or know of reason why should so?

<form> <p>enter text in input box, click 1 of buttons.</p> <input type="text"><br> <input type="button" onclick="alert('what happens form values?')" value="input button">    <br> <button onclick="alert('what happens form values?')">html button</button> </form> 

the <button> submitting form when clicked.
submitting form reloads page.

to prevent this, add return false end of handler.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -