开发者

GreaseMonkey Document.Write or post HTMl at end?

I am trying to use document.write(html); in my script but it looks illegal. I would like to write some html at the end of my document in a GM script. How do i do thi开发者_StackOverflow社区s?


Simplest would be:

document.body.innerHTML += 'some html';

More robust and complex is to use DOM methods:

var myDiv = document.createElement('div');
myDiv.innerHTML = 'some text'; // yes, yes I am cheating here again but
                               // what did you expect from a short example?

document.body.appendChild(myDiv);

See the Gecko_DOM_Reference for more info about the DOM API.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜