是否可以跟踪页面中的所有表单提交(例如使用 javascript)?

发布于 2024-10-24 16:11:32 字数 311 浏览 0 评论 0原文

假设我创建并提交了几个表单和一些动态表单(也在几个框架中) 是否可以追踪这些表单的提交(至少在同一框架中)?
我知道用于附加到表单的 onsubmit 事件,但是如果我不知道表单并且有些表单甚至是动态创建的怎么办? (在 document.forms[] 上运行不会有帮助)。
是否有一些通用的 onsubmit 事件或 window.onsubmit 可以捕获页面上的所有提交?

其他问题是是否有类似的东西可以在触发 href 之前捕获用户的任何 HREF 点击? (同样是在事先不知道他们的情况下)。

谢谢,
塔尔

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,
Tal

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

不甘平庸 2024-10-31 16:11:32

当然 document.forms 可以工作。

您只需在创建测试时将测试添加到 onsubmit 中,或者需要定期扫描 document.forms。

但是,只有将事实保存在某处,您才会知道它们已提交。如果表单提交到当前页面,您将需要一个 cookie。如果它们被提交到新窗口或框架,那么您可以将计数器保留在页面中。

如果您能告诉我们为什么要这样做,那就太好了。也许我们建议您按照您的最终结果去做,而不是告诉您如何做您认为您需要的事情。

Of 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文