我正在使用 document.write 为 Chrome 扩展编写页面文本,但相关的自定义 CSS 并未应用:
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还是两者都有呢?
showFolder
函数?你有其他可能会冲突并覆盖样式的样式表吗?我测试了你这里的代码,如果你在函数声明后调用showFolder
而不是在...
处调用,它在 Google Chrome 中可以正常工作。 - John Rasch