小编hid*_*yho的帖子

css没有应用于document.write文本

我正在使用document.write为Chrome扩展程序将文本写入页面,但未应用关联的自定义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>
Run Code Online (Sandbox Code Playgroud)

CSS很简单,只是用于调试:

p {
color: red;
}
Run Code Online (Sandbox Code Playgroud)

如果我将样式表链接放在函数showFolder中,我可以使它工作,但这不是正确的方法.我正在学习jscript/CSS,所以答案可能是补救措施.是jscript,CSS还是两者都有问题?

javascript css document.write

6
推荐指数
1
解决办法
7450
查看次数

标签 统计

css ×1

document.write ×1

javascript ×1