Is it possible to track all form submits in a page (using javascript for instance)?
Assuming I have several forms and a few dynamic forms created and submitted (also in a few frames) Is it possible to track down the submit of these forms (at least in same frame) ?
I know the onsubmit event for attaching to the开发者_开发问答 forms, but what if I don't know the forms and some are even created dynamically? (running on document.forms[] won't assist here). Is there some general onsubmit event or window.onsubmit that catches all the submits on page?Additional questions is whether there is something similar to catch any HREF click of a user before href is being fired? (again without knowing them in advance).
Thanks,
TalOf course document.forms will work.
You just need to EITHER add your test to the onsubmit when they are created, or you need to scan the document.forms on a regular basis.
However you will only know they are submitted if you save the fact somewhere. If the form is submitted to the current page, you would need a cookie. If they are submitted to a new window or to a frame, then you can keep the counter in the page.
It would be great if you would tell us WHY you want to do this. Perhaps we have a suggestion to do what your end result is rather than tell you how to do what you think is what you need.
精彩评论