Skip to content

cross browser function to dynamically load an external css file

License

Notifications You must be signed in to change notification settings

intesso/jquery-getCSS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

jquery-getCSS

cross browser function to dynamically load an external css file. see: github page

Usage

Download the file jquery.getCSS.js and include it in the header of your html:

	<script src="jquery.getCSS.js"></script>

if jQuery is loaded it adds the getCSS function to the jQuery object:

	$.getCSS("getCSS.css");

Otherwise it adds it to the window object:

	window.getCSS("getCSS.css");

Options

the function takes an attributes hash or a string

	// file name as string:
	$.getCSS("fresh.css")

	// attributes as hash:
	$.getCSS({href:"cool.css", media:"print"})
	$.getCSS({href:"/styles/forest.css", media:"screen"})	

Testing

Tested with Firefox, Chrome, IE

Open this link: Test Page and click applyCSS and the external css file should be loaded and the styles should be applied.

Credits

Original Idea by: Soviut http://stackoverflow.com/questions/1184950/dynamically-loading-css-stylesheet-doesnt-work-on-ie

References

IE special: http://msdn.microsoft.com/en-us/library/ie/ms531194(v=vs.85).aspx

License

MIT License

Support or Contact

Having trouble with this script? Please let me know: [email protected].

About

cross browser function to dynamically load an external css file

Resources

License

Stars

Watchers

Forks

Packages

No packages published