我在我的頁面中創建一個iframe
這裏是它的代碼:負載事件不會在IE
var frame = document.createElement('iframe');
frame.setAttribute('src','');
document.body.appendChild(frame);
if(document.addEventListener){
frame.addEventListener('load', callback, false);
} else {
frame.attachEvent('onload', callback);
}
function callback(){
alert('test');
}
它工作正常,在FF,但沒有在IE驚動的事,爲什麼呢?
請注意,我用IE10在Win8中
什麼是控制檯輸出後移動到
document.body.appendChild()
? –@JeroenIngelbrecht我在IE控制檯中找不到任何東西! –
attachEvent返回什麼?真假嗎? http://msdn.microsoft.com/en-us/library/ie/ms536343(v=vs.85).aspx –