私は、インラインコンテンツ(広告バナー)を追加する)(のdocument.writeで関数を呼び出す:ページ上ののdocument.write()のsetTimeout()内のすべてのページを上書き
<body>
Page content start<br>
<script>
function postContent(){
document.write('added content');
}
postContent();
</script>
<br>Page content end
</body>
私が得ました:
Page content start
added content
Page content end
このコンテンツを遅延で追加したいのですが、setTimeout()内にdocument.write()がすべてのコンテンツを上書きします。 3S内
ページの<body>
Page content start<br>
<script>
function postContent(){
document.write('added content');
}
setTimeout(function() {
postContent();
}, 3000);
</script>
<br>Page content end
</body>
は、私が得た:
added content
はどうすれば遅延でのdocument.write()で関数を呼び出すことができますし、すべてのページを上書きしませんか?
注:私は広告バナーを挿入する機能にアクセスできません。
あなたが 'にdocument.write()'自体を使用する必要がありますか? – DroidNoob
insertAdjacentHtmlはどうですか? – funcoding
HTMLドキュメントが完全に読み込まれた後にdocument.write()を使用すると、既存のHTMLがすべて削除されます。 – CaptainHere