2015-01-07 230 views
1

有點尷尬。我曾嘗試在谷歌Chrome,莫茲FF,歌劇一個簡單的腳本,它的工作原理就像一個魅力在那裏,按理說應該以及在IE,但不知何故,IE告訴我錯誤 - IE 11「對象不支持屬性或方法appendChild」在元素節點上

對象不支持屬性或方法「使用appendChild」

奇怪的是,我的代碼是唯一的:

var close = document.createElement('button'); 
close.type = 'button';  
close.appendChild(document.createTextNode('CLOSE')); 

我沒有在IE瀏覽器關閉安全設置,以使腳本運行,因爲它是一個書籤內(所以DRA在頁面上顯示)。我發現這篇文章:appendChild not working with window.open in IE,它說IE塊在不同的窗口上下文中的appension。但就我而言,我應該如何在窗口中追加它?

+0

它自身工作,而無需運行它裏面書籤爲我工作? –

回答

0

我使用幾乎相同的代碼創建了一個書籤,它使用IE11

javascript:(function(){ 
    var close = document.createElement('button'); 
    close.type = 'button'; 
    close.appendChild(document.createTextNode('CLOSE')); 
    document.getElementsByTagName('body')[0].appendChild(close); 
    })(); 
相關問題