0

I'm trying to write one line of CSS using vanilla JavaScript inside the document.body, but right before the closing </body> tag.

What am I doing wrong, why isn't this working?

document.body.write('<style type="text/css">#input, #backgroundFix{ background:url(dawn.svg) top left repeat-x; }</style>');
4

1 回答 1

2

假设您的脚本也位于结束标记之前,则它是document.write,不是。document.body.write</body>

如果没有,请document.createElement改用。

于 2013-05-01T23:28:00.163 回答