javascript - Dynamically loading css stylesheet doesn't work on IE -


I dynamically load a CSS stylesheet (with a little help from jQuery):

 < Code> Var head = document.getElementsByTagName ('head') [0]; $ (Document.createElement ('link')) .attr ({type: 'text / css', href: '../../mz/mz.css', rel: 'stylesheet'}) .appendTo (head );  

It works fine in Firefox and Google Chrome, but not in IE

Any help? Thanks

Once IE has processed all the styles loaded with the page, another stylesheet The only reliable way to add is with document.createStyleSheet (url)

See on CreateStyleSheet for some more details.

  url = 'style.css'; If (document.createStyleSheet) {document.createStyleSheet (url); } And {$ ('& lt; link rel = "stylesheet" type = "text / css" href = "' + url + '" />').appendTo('head'); }  

Comments

Popular posts from this blog

email - PHP mail error ... failed to open stream : permission denied -

c# - ListView onScroll event -

c - Linux mmap() error -