Team:HSAAHNU Anhui/inject.js

From 2014hs.igem.org

(Difference between revisions)
(remove default styles)
m (content type fixed)
Line 26: Line 26:
var injections = [
var injections = [
   '<link href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">',
   '<link href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">',
-
   '<link href="/Team:HSAAHNU_Anhui/normalize.css?action=raw&ctype=text/stylesheet" rel="stylesheet">'
+
   '<link href="/Team:HSAAHNU_Anhui/normalize.css?action=raw&ctype=text/css" rel="stylesheet">'
];
];
document.head.innerHTML += injections.join('\n');
document.head.innerHTML += injections.join('\n');

Revision as of 11:46, 27 May 2014

function removeStyleNodes () {

 var styleNodes = document.head.getElementsByTagName('style');
 while (styleNodes.length != 0) {
   document.head.removeChild(styleNodes[0]);
 }

}

function removelinkStylesheetNodes () {

 var linkNodes = document.head.getElementsByTagName('link');
 var nonStylesheetLinksCounter = 0;
 var iter = 0;
 while (linkNodes.length != nonStylesheetLinksCounter) {
   var node = linkNodes[iter];
   if (node['rel'] == 'stylesheet')
     document.head.removeChild(node);
   else {
     nonStylesheetLinksCounter ++;
     iter ++;
   }
 }

}

removeStyleNodes(); removelinkStylesheetNodes();

var injections = [

 '<link href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">',
 '<link href="/Team:HSAAHNU_Anhui/normalize.css?action=raw&ctype=text/css" rel="stylesheet">'

];

document.head.innerHTML += injections.join('\n');