addEventListener到iFrame [英] addEventListener to iFrame
本文介绍了addEventListener到iFrame的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
$(#myIFrame)。内容().find(body)。bind(mouseup,function(){
//e.preventDefault(); //没有区别
alert('inside');
});
这不行。任何想法?
解决方案
这将工作:
$('#myIFrame')。load(function(){
//然后设置一些访问点
var contents = $(this).contents(); // iframe的内容
$(contents).find(body)。on('mouseup',function(event){
alert('test');
});
});
I'm tryin to add event listener to mouseup inside iframe object:
$("#myIFrame").contents().find("body").bind("mouseup", function() {
//e.preventDefault(); //doesn't make difference
alert('inside');
});
This doesn't work. Any ideas?
解决方案
This will work:
$('#myIFrame').load(function(){
//then set up some access points
var contents = $(this).contents(); // contents of the iframe
$(contents).find("body").on('mouseup', function(event) {
alert('test');
});
});
这篇关于addEventListener到iFrame的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文