我寫文本使用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`而不是``` – 2011-01-25 03:45:23
showFolder從另一個函數(...)中調用,它讀取Chrome書籤中的文件夾(基本上是'讀取書籤樹' - >'如果item是文件夾,則通過showFolder顯示文件夾的名稱)。只是爲了踢我移動showFolder聲明之前......功能,但問題依然存在。 – hideyho 2011-01-25 04:11:32