Team:HSAAHNU Anhui/inject.js
From 2014hs.igem.org
(Difference between revisions)
(content type changed) |
(remove default styles) |
||
Line 1: | Line 1: | ||
+ | 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 = [ | 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/ | + | '<link href="/Team:HSAAHNU_Anhui/normalize.css?action=raw&ctype=text/stylesheet" rel="stylesheet">' |
]; | ]; | ||
- | document. | + | document.head.innerHTML += injections.join('\n'); |
Revision as of 11:45, 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/stylesheet" rel="stylesheet">'
];
document.head.innerHTML += injections.join('\n');