jQuery 为 iframe的body添加click事件

html结构如下:

 
 
1 < html > 2 < head > 3 < title > 为body添加click事件 </ title > 4 < meta http-equiv ="content-type" content ="text/html;charset=utf-8" > 5 < script type ="text/javascript" src ="jquery-1.5.2.js" ></ script > 6 < script > 7 function show_body_click(){ 8 alert( ' you are click the body ' ); 9 } 10 jQuery(document).ready( function (){ 11 // jQuery("ifr_id").contents().find("body").attr("onclick", "show_body_click()"); 12   //alert(jQuery( " #ifr_id " ).contents().find( ' body ' ).attr( " onclick " , ' xxxx() ' ));//不能实现 13 // var ifr = jQuery("ifr_id") 14 }); 15 jQuery(document, ' #ifr_id ' ).ready( function (){ 16 jQuery( " #ifr_id " ).contents().find( " body " ).attr( " onclick " , " parent.show_body_click() " ); 17 // jQuery("#ifr_id").contents().find("body").live("click", "parent.show_body_click()");//ff没有效果 18 // jQuery("#ifr_id").contents().find("body").click(parent.show_body_click()); //ff没有效果 19 }); 20 21 </ script > 22 </ head > 23 < body id ="body_id" > 24 < span > 25 < iframe id ="ifr_id" src ="eval.html" height ="100px" width ="800px" ></ iframe > 26 </ span > 27 </ body > 28 </ html >

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值