简体   繁体   English

如何在iframe广告代码上使用onclick

[英]How to use onclick on a iframe tag

How to use onclick in iframe tag to call a javascript. 如何在iframe广告代码中使用onclick来调用JavaScript。

I basically want redirect to other page when a user clicks on a iframe.I have added the facebook like button my site which is a iframe code. 我基本上想在用户单击iframe时重定向到其他页面。我在我的网站上添加了Facebook之类的按钮,这是iframe代码。 So once he has clicked on the like button i want him to get redirected to a thank you page 因此,一旦他单击了“赞”按钮,我希望他被重定向到“谢谢”页面

EDIT: i don't want to redirect the iframe but i want to redirect the main page on any interactivity with iframe. 编辑:我不想重定向iframe,但我想在与iframe进行任何交互时重定向主页。 On solution is on focus or or on click on iframe i should be able to redirect. 关于解决方案的重点是或单击iframe,我应该能够重定向。 Can i at least do it. 我至少可以这样做。

You can't do that. 你不能那样做。 Facebook's XFBML elements (like the 'Like' button) are on a different domain than your own (and only function that way); Facebook的XFBML元素(如“赞”按钮)与您自己的域不在同一个域(并且仅以此方式运行); using Javascript to modify that frame isn't possible due to security restrictions. 由于安全性限制,无法使用Javascript修改该框架。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM