【发布时间】:2013-12-27 19:57:57
【问题描述】:
我有一个网页,在该网页中,我使用页面 bootom 中的 javascript 代码在 head 部分添加了一个 css 文件:
$(document).ready(function(){
var css=document.createElement('link');
css.type='text/css';
css.href='/css/user.css';
css.rel='stylesheet';
document.getElementsByTagName('head')[0].appendChild(css);
});
所以当用户禁用 javascript 时我遇到了问题,然后无法将 thic 文件添加到页面中,所以有什么方法可以使用在该页面中包含 css 文件
<noscript>..Code..</noscript>
我无法将此文件直接添加到我的 head 部分中。
那么是否可以在不使用的情况下将 css 文件添加到我的 html 文档中 javascript?
【问题讨论】:
-
你可以编写内联样式。
-
@Leifingson 我不能使用内联样式,因为这个文件在多个页面中使用,所以它给我带来了很多工作。
-
什么原因,没有添加到head部分?
-
@Himalya Vashistha 同样你可以把
标签: javascript jquery html css