问题描述
我知道这有跨站点脚本限制但是我想知道是否有办法做到这一点...
I know this has cross site scripting limitations however I was wondering if there is a way to do this...
我有一个使用第三方的客户网站向用户展示调查。调查网站确实提供了包含在您网站上的iframe代码,因此您可以通过自己的网站向用户展示调查问卷。当用户单击iframe中的提交按钮时,客户希望捕获一些数据。我不需要访问调查中的任何表单字段,我只需要在javascript中定义一个额外的自定义事件,当在iframe中单击提交按钮时会触发该事件。这可能吗?怎么样?
I have a customer who uses a 3rd party website to present surveys to users. The survey site does provide iframe code to include on your site so you can present the survey to your users from your own site. The customer wants to capture some data when the user clicks the submit button within the iframe. I don't need access to any form fields within the survey I just need to some how define an additional custom event in javascript that gets fired when the submit button is clicked in the iframe. Is this possible? How?
谢谢!
推荐答案
没办法办这是由于跨站脚本。如果您有权访问iframe内容和外部框架,那么您可以使用事件在两者之间进行通信。但是你当然无法控制iframe内容。
There is no way to do this due to the cross site scripting. If you had access to both the iframe content and the outer frame then you could have used events to communicate between the two. But of course you have no control over the iframe content.
如果您有访问权限,则可以发布消息以获取对事件的访问权限。这是一个插件。
If you had access then you could have post a message to get access to the events. Here is a plugin. http://benalman.com/projects/jquery-postmessage-plugin/
这篇关于如何在其他域上捕获iframe的点击次数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!