我正在为 Chrome 扩展使用 document.write 将文本写入页面,但未应用关联的自定义 CSS:
<!DOCTYPE html>
<html>
<head>
<title>TITLE GOES HERE</title>
<link rel="stylesheet" href="css/popup.css" type="text/css" />
</head>
<body>
<script type="text/javascript">
...
function showFolder(folder) {
console.debug('FOLDER: '+folder.title);
document.write('<p>'+folder.title+'<br></p>');
}
</script>
</body>
</html>
CSS 很简单,仅用于调试:
p {
color: red;
}
如果我将样式表链接放在函数 showFolder 中,我可以让它工作,但这不是正确的方法。我正在学习 jscript/CSS,所以答案可能是一些补救措施。是 jscript、CSS 还是两者都有问题?