开发者

Not allowed document.write after page load?

I've been told that you can't use document.write after a page load, is this true?

I've created an extremely simple Javascript file that gets included from websites which serves as an advertising s开发者_运维百科cript. It just includes a document.write('Link Here'). I've been told that I should not do this though as apparently it isn't correct, and it will stop the page from loading?

Is this true? It works fine for me.

Thanks


If you just write to the document itself it'll remove the page content and you'll be left with only the new text.

Try using:

document.getElementById('DIVID').innerHTML = "YOUR HTML HERE"

Substitute 'DIVID' for the element that will contain the ad and 'YOUR HTML HERE' for whatever you want to be written to the page). This will also allow you to position the ad on the page more easily.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜