Skip to content

Commit

Permalink
Works in IE8 now too.
Browse files Browse the repository at this point in the history
  • Loading branch information
SeanMcMillan committed Apr 3, 2011
1 parent 6d2d6ee commit c14d17b
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 14 deletions.
40 changes: 30 additions & 10 deletions exploration/cgrade.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,49 @@
(function() {
(function(document) {
var target,
SCRIPT = "script",
TEXTJS = "text/javascript",
STYLE = "style",
TEXTCSS = "text/css";

function theTest() {
return true;
}

function preTest() {
target = document.getElementsByTagName(SCRIPT)[0];
return true;
}

function buildDynamicTag(tag, type) {
var elem = document.createElement(tag);
elem.type = type
return elem;
}

function putInHead(elem) {
target.parentNode.insertBefore(elem, target);
}

function loadJsAsynch() {
var script = document.createElement("script");
script.type = "text/javascript";
script.async = true;
var script = buildDynamicTag(SCRIPT, TEXTJS);
script.async = true; // should this be "true"? string v bool
script.src = "main.js";

var target = document.getElementsByTagName("script")[0];
target.parentNode.insertBefore(script, target);
putInHead(script);
}

function insertFoucPreventer() {
$(document.documentElement).removeClass("no-js").addClass("js loading");

var foucPreventer = $("<style/>").text(".loading .hideload {display:none};");
var target = document.getElementsByTagName("script")[0];
target.parentNode.insertBefore(foucPreventer.get(0), target);
var style = buildDynamicTag(STYLE, TEXTCSS);
var css = ".loading .hideload {display:none};";
if (style.styleSheet) {
//weird IE way
style.styleSheet.cssText = css;
} else {
style.appendChild(document.createTextNode(css));
}
putInHead(style);
}

function doIt() {
Expand All @@ -34,4 +54,4 @@
}

doIt();
})();
})(window.document);
6 changes: 3 additions & 3 deletions exploration/main.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(function() {
$("#nojs").text("Content for Passing Browsers");
$(function() {
$("#nojs").text("Content for Passing Browsers").css({color:'green'});
$("html").removeClass("loading");
})();
});
2 changes: 1 addition & 1 deletion exploration/simple.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<body>


<h1 id="nojs" class="hideload">Content for Failing Browsers</h1>
<h1 id="nojs" class="hideload" style="color:red">Content for Failing Browsers</h1>

<h2>Content for everybody</h2>

Expand Down

0 comments on commit c14d17b

Please sign in to comment.