jquery给页面上的iframe添加click或者是focus事件

这个功能研究了许久也不行。

下面是代码:没时间继续研究了。用了一个其他的方法区取代。谁看到,可以继续研究。

第一个new.html页面中有一个iframe去加载eval.html。

new.html

<html>
	<head>
	
	
		<meta http-equiv="content-type" content="text/html;charset=utf-8">
		<script type="text/javascript" src="jquery.js"></script>
		<script>
		
		
		// jQuery("#test").append("test!"+"</br>");
	       
		
	function show_body_click() {
		jQuery("#ifr_id").contents().find("body").append('you are click the body');
	}
	
	
	$(function(){ 
		jQuery("#ifr_id").load(function(){ 
	      
	      	jQuery("#ifr_id").contents().find("body").html("test this is inner body!");
			jQuery("#ifr_id").contents().find("body").bind("click","alert('dd')");
			//top.show_body_click()
	    });
    });
</script>
	</head>
	<body id="body_id">
		<span> <iframe id="ifr_id" src="eval.html" height="100px"
				width="800px"></iframe> </span>
				<div id="test"></div>
	</body>
</html>


eval.html

<html>
	<script type="text/javascript" src='jquery.js'></script>
	<script type="text/javascript">

</script>
	<body>
		this is eval.html
	</body>
</html>


最后采取的方法:不用iframe了。而是用div,使用jQuery("#id").load('a.html')的方法来家在其他页面。

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值