1. What is the default behavior?
In our HTML tags, many tags have their own default behavior.
Such as:
Submit button: It will automatically submit the form data to the processing page
A tag: It will automatically jump to the specified page
In some cases, we don't need this default behavior.
Such as:
When we do not fill out the form data, the system should not submit the form data directly to the processing page.
When we click the Delete link, if the user does not confirm that it should not be deleted directly.
2. Organization Default behavior
IE Model Browser
Window.event.returnValue = false;
Model Browser
Dom object. event = function (event) {
Event.preventdefault ();
}
Example code:
<!DOCTYPE HTML><HTML><Head><MetaCharSet= ' utf-8′><title></title><Scriptsrc= ' Public.js '></Script><Script>window.onload= function() {$ (' Btnok '). OnClick= function(){if($ (' username '). Value==") {alert (' user name cannot be null ');//IE Model//Window.event.returnValue = false;//ModelEvent.preventdefault (); }}}</Script></Head><Body><formAction= "4.html"Method= "POST">Name:<inputtype= "text"ID= "username"><HR/><inputtype= "Submit"ID= "Btnok"name= "Submit"value= ' Register '></form></Body></HTML>
Kill lui lei dog---javascript no:16 default behavior 1