2015-01-07 231 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); 
    })(); 
相关问题