var style = document.createElement("style");

style.type = "text/css";

try{

  style.appendChild(document.createTextNode("body{background-color:red}"));

}catch(ex){

  style.styleSheet.cssText = "body{background-color:red}";//针对IE

}

var head = document.getElementsByTagName("head")[0];

head.appendChild(style);

 

相关文章:

  • 2022-12-23
  • 2021-11-12
  • 2021-10-16
  • 2022-12-23
  • 2022-12-23
  • 2021-06-24
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-10-30
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案