Home  >  Article  >  Web Front-end  >  About using JavaScript to intercept form's submit method implementation

About using JavaScript to intercept form's submit method implementation

高洛峰
高洛峰Original
2016-11-26 14:06:552271browse

About using JavaScript to intercept the submit method of the form

Posted on 2006-12-23 10:37 winder

Recently, I encountered the need to use JS script to uniformly intercept the submit method of the form in the page to modify the request when the page is implicitly submitted. The URL is simply implemented as follows:
Var OldSubmit;
var Form = Document.Forms [0];
If (Form! = NULLLLLL! = 'Undefined') {
// Form.oldsubmi t = FORM. submit; /// cover the submit function to achieve intercepting
Form.submit = function () {
// The operation before submit ..
// Drop the original function to submit
form.oldsubmit ();
}}}}
The above code will be intercepted when it is executed first when the page is loaded. For submissions that are displayed using the submit button, you can monitor the onsubmit event to achieve this. There are many methods for this and there is no big problem.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn