From 9928ed80b774c8e718c6c584aa7a956e6dd6c49b Mon Sep 17 00:00:00 2001 From: Adrien Lochon Date: Wed, 3 Oct 2012 22:47:17 +0200 Subject: [PATCH] Update responsive-retrofit.js Added compatibility for Firefox & Internet Explorer (and possibly others... care to test?). --- responsive-retrofit.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/responsive-retrofit.js b/responsive-retrofit.js index cb4b87f..4984044 100755 --- a/responsive-retrofit.js +++ b/responsive-retrofit.js @@ -1,10 +1,17 @@ (function() { + var fileUrl = "http://sparkbox.github.com/Responsive-Retrofitting/" + document.location.hostname + "/css/retrofit.css"; + var cssLink = document.createElement('link'); cssLink.setAttribute('rel', 'stylesheet'); - cssLink.setAttribute('type', 'text/stylesheet'); - cssLink.setAttribute('href', "http://sparkbox.github.com/Responsive-Retrofitting/" + document.location.hostname + "/css/retrofit.css"); - document.head.appendChild(cssLink); + cssLink.setAttribute('type', 'text/css'); // Changed the type from "text/stylesheet" to "text/css". This makes it work for Firefox. + cssLink.setAttribute('href', fileUrl); + + if (document.createStyleSheet) { + document.createStyleSheet(fileUrl); // With IE, you must use createStyleSheet + } else { + document.head.appendChild(cssLink); + } // Add meta tag, too! var metaCode = document.createElement('meta');