当前位置: 代码迷 >> JavaScript >> 小弟我向在<head></head>中用javascript动态增加一行<link .>
  详细解决方案

小弟我向在<head></head>中用javascript动态增加一行<link .>

热度:399   发布时间:2012-03-02 14:40:29.0
我向在<head></head>中用javascript动态增加一行<link ...>
如题
谢谢

------解决方案--------------------
var head=document.getElementsByTagName( "HEAD " );
var new_link = document.createElement( 'link ' );
new_link.type = 'text/css ';
new_link.href = 'css/style.css ';
head[0].appendChild( new_link );
------解决方案--------------------
var head=document.getElementsByTagName( "HEAD " );
var new_link = document.createElement( 'link ' );
new_link.type = 'text/css ';
new_link.href = 'css/style.css ';
new_link.rel= "stylesheet "; //还要加上这句才行
head[0].appendChild( new_link );
  相关解决方案