检测单击Iframe然后执行操作 [英] Detect Click On Iframe Then Do An Action

查看:151
本文介绍了检测单击Iframe然后执行操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想为我的网站添加一个iframe,其中有一个按钮,当有人点击它时,它会执行一个操作,例如转发到另一个网页或回显讯息。我不关心代码是否它的java,php,html等,只要它工作。

I want to add a iframe to my website that has a button in it and when someone clicks on it, it does an action like maybe forward to another page or echo a message. I don't care about the code whether its java, php, html, etc as long as it works. I'm good at coding certain things but this is not one of them, help me out please.

更新:
iframe是:
iframe src =http://ipget.tk/ iframe

UPDATE: the iframe is: iframe src="http://ipget.tk" /iframe

点击时我想要转到google.com
iframe将会在scazioco.com的测试页上

when its clicked on I want it to go to google.com the iframe will be on a test page on scazioco.com

推荐答案

使用Jquery,您可以将事件绑定到IFrame:

Using Jquery you can bind an event to your IFrame :

    $('#iframe_id').bind('click', function(event) { 
        window.location = http://www.google.com    
     });

将#iframe_id替换为实际的Iframe ID

Replace #iframe_id with the actual Iframe's ID

这篇关于检测单击Iframe然后执行操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆