About how to use JavaScript to intercept form submit
Source: Internet
Author: User
About the use of JavaScript to intercept form submit method to achieve Postedon2006-12-2310: 37winder recently encountered the need to use JS scripts to intercept the form of a unified page in the submit method to modify the request URL when the page is implicitly submitted simple implementation is as follows: varoldSubmit; varfo... synt submit Method for Intercepting form with JavaScript
Posted on winder
In the near future, we need to use JS scripts to intercept the form submit method on the page to modify the request URL when the page is implicitly submitted. The simple implementation is as follows:
Var oldSubmit;
Var form = document. forms [0];
If (form! = Null & form! = 'Undefined '){
// Back up the submit Function
Form. oldSubmit = form. submit;
// Override the submit function for interception
Form. submit = function (){
// The operation before submission ..
// Submit the original function
Form. oldSubmit ();
}
}
The above code will be intercepted when it is first executed during page loading. The onsubmit event can be monitored when the submit button is used for display. There are no major problems with this method.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service