Detect Click On Iframe Then Do An Action

▼魔方 西西 提交于 2019-12-13 04:28:45

问题


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.

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

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


回答1:


Using Jquery you can bind an event to your IFrame :

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

Replace #iframe_id with the actual Iframe's ID



来源:https://stackoverflow.com/questions/15509671/detect-click-on-iframe-then-do-an-action

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!