Posted By

szsk on 08/02/06


Tagged

css javascript Opera datascheme


Versions (?)

addStyleSheet for Opera8.*


 / Published in: JavaScript
 

URL: http://bmky.net/diary/log/1368.html

this script need "function btoa" http://snipplr.com/view/702/base64encode/

  1. function addStyle( selector, property ) {
  2. var cssText = selector + "{" + property + "}";
  3. var href = "data:text/html;charset=utf-8;base64," + btoa( cssText );
  4. createStyleSheet( href );
  5. }
  6.  
  7. function createStyleSheet( href ) {
  8. var link = document.createElement( "link" );
  9. link.rel = "stylesheet";
  10. link.href = href;
  11. link.type = "text/css";
  12. var head = document.getElementsByTagName( "head" ).item( 0 );
  13. head.appendChild( link );
  14. }

Report this snippet  

You need to login to post a comment.