如何將點擊事件分配給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!!!');
})
});
});
感謝您的幫助。
你不能(根據大多數瀏覽器)。 –
也許你應該嘗試獲取該頁面的內容並自行追加。 –