使用 iframe 插入 Web 表单时 jQuery 发生冲突
我必须将表单嵌入到开发网站中。该表单将托管在同一域上,但我无法编辑包含该表单的文档的任何内容。
我的问题是,包含表单的文档使用的是非常旧的 jQuery 版本,并且想知道这是否会导致与父站点上的 vaersion(最新)发生冲突。
I am having to iframe a form into a development site. The form will be hosted on the same domain but i am not able to edit any of the contens of the document that contains the form.
My issue is that the document that contains the form is using a very old version of jQuery and was wondering if this is going to cause conflicts with the vaersion (latest) on the parent site.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不会有冲突,两个文件是完全分开的。两个 DOM 之间可以进行交互,但实际脚本无法看到对方。这使得 iframe 成为沙箱的理想选择。
There will be no conflicts, the two documents are completely separate. It is possible to interact between the two DOMs, the actual script cannot see each other. This makes
iframe
s ideal for sand-boxing.在 DOM 范围内,两个不同的 jQuery 实例在父框架和 iFrame 内容之间不会发生冲突。这并不是说您不能有冲突的 javascript,因为它与您的浏览器对象有关,但如果您的行为仅与文档相关,那么应该没问题。您的方法和属性不会在多个源框架之间交叉污染。
In scope of DOM, your two different jQuery instances won't be in conflict between your parent frame and the iFrame content. This is not to say you cannot have conflicting javascript as it pertains to your browser objects, but if your behaviors are only document related, you should be fine. Your methods and properties won't cross contaminate between multiple source frames.