![](/img/trans.png)
[英]Programmatically detect when or right before closing Body Tag is hit on a web page using JS?
[英]Writing CSS right before the closing body tag
我正在嘗試在document.body
使用vanilla JavaScript編寫一行CSS,但是在結束</body>
標記之前。
我做錯了什么,為什么這不起作用?
document.body.write('<style type="text/css">#input, #backgroundFix{ background:url(dawn.svg) top left repeat-x; }</style>');
它是document.write
,而不是document.body.write
,假設您的腳本也在結束</body>
標記之前。
如果沒有,請改用document.createElement
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.