Include CSS Stylesheet by DOM | JavaScriptSource

Include CSS Stylesheet by DOM

Benoit Asselin Oct 12, 2007


Use this script when you want to use the DOM to include a cascading style sheet. Very simple to implement.


Source Code

Paste this source code into the designated areas.

External file

Paste this code into an external JavaScript file named: includeCSS.js


Paste this code into the HEAD section of your HTML document.

Leave a Response



John Carter May 22, 2013

Ok this

Style Sheet Jul 13, 2012

Sorry, interested but why would I want to do this?[br /][br /]Can it be integrated with jquery?[br /][br /]Bit of a novice I'm afraid.

rodger myles Nov 12, 2007

You would call the function something like this:[br /][br /]window.onload = function() {[br /] includeCSS('style/yourStyle.css');[br /]}

Lee Oct 26, 2007

An example of how to use this would be very useful, please.

David IB Oct 13, 2007