【发布时间】:2014-02-25 12:01:33
【问题描述】:
这是简化的代码,它在 appendChild 行之后停止工作:
$preview = {
designImg: '',
thePage: null,
designPreviewer: null,
init: function(){
var divNode = $('<div>').attr('id','layoutVsDesign').html('test');
document.body.appendChild( divNode );
alert('I never happen');
this.designPreviewer = document.body.find('#designPreviewer');
}
};
$(document).ready(function(){
$preview.init();
});
知道我错过了什么吗?
我也试过了:
chrome.extension.getBackgroundPage().appendChild()
结果几乎相同
-编辑-
有效(接受一个字符串):
chrome.tabs.executeScript({
code: 'document.body.style.display = "none"'
});
但是
chrome.tabs.executeScript({
code: 'document.body.appendChild("<div>tttttttesttt</div>")'
});
或
chrome.tabs.executeScript({
code: 'document.body.appendChild(node[0])'
});
不行,如何将节点传递给code参数?
【问题讨论】:
标签: javascript google-chrome dom google-chrome-extension appendchild