This creates a style node and appends it to the head element. I use this in Greasemonkey to style other stuff I add to certain pages. I won't go into that here.
You may not have to use the setAttribute() function. Comparing the Use iframe contents to change iframe to ajax div entry, you may be able to use style.type="text/css";
//put the style in first so my div doesn't jump around
var styles = document.createElement('style');
var newStyle = document.createTextNode(mystyle);
var headRef = document.getElementsByTagName('head');
last edited on January 14th, 2010 at 2:20 PM
- Walid on "Adventures with Ubuntu 9.10 on G4 Yikes!" - I am in the same process as you. Although I still dual-boot to Windows for my ganimg leisure. My first contact with Ubuntu was way…
- Slashback on "Simpler adding & removing element classnames" - Actually, the addClassName function does what you want, pretty much the same way you suggest.
- angie on "Simpler adding & removing element classnames" - And what if I want to add a class, but keeping the csseals the element already has?I mean, I have an element with a class, let's name…
- backlinks on "Adjust iframe height to contents" - Definitely helped me.
- Slashback on "Simpler validate form fields are filled in (no additional class names)" - You are welcome!