如何将点击事件分配给ifraem内的元素?如何将点击事件分配给iframe中的元素?
我开始了一篇文章,检测iframe是否被加载。
How can I detect whether an iframe is loaded?
和我有进一步的quesitons
如何分配一个事件或操作iframe中的元素?
我试过..
$(function(){
$('#click').on('click', function(){
var ifr=$('<iframe></iframe>', {
id:'MainPopupIframe',
src:'http://heera.it',
style:'display:none',
load:function(){
$(this).show();
alert('iframe loaded !');
}
});
$('body').append(ifr);
//when I click the home page button, nothing happen...
$('#menu-item-277').click(function(){
alert('click!!!');
})
});
});
感谢您的帮助。
你不能(根据大多数浏览器)。 –
也许你应该尝试获取该页面的内容并自行追加。 –