Skip to content

Instantly share code, notes, and snippets.

@chrismay
Last active October 11, 2016 14:09
Show Gist options
  • Save chrismay/64989cdeaa94a10fa5fe to your computer and use it in GitHub Desktop.
Save chrismay/64989cdeaa94a10fa5fe to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title> - jsFiddle demo</title>
<style type='text/css'>
</style>
<script type='text/javascript'>//<![CDATA[
var VanillaRunOnDomReady = function() {
var content = document.getElementById("content");
for (i=0; i<=10;i++){
var newLine = document.createElement("p");
newLine.appendChild(document.createTextNode("This is paragraph number " + i));
content.appendChild(newLine);
}
}
var alreadyrunflag = 0;
if (document.addEventListener)
document.addEventListener("DOMContentLoaded", function(){
alreadyrunflag=1;
VanillaRunOnDomReady();
}, false);
else if (document.all && !window.opera) {
document.write('<script type="text/javascript" id="contentloadtag" defer="defer" src="javascript:void(0)"><\/script>');
var contentloadtag = document.getElementById("contentloadtag")
contentloadtag.onreadystatechange=function(){
if (this.readyState=="complete"){
alreadyrunflag=1;
VanillaRunOnDomReady();
}
}
}
window.onload = function(){
setTimeout("if (!alreadyrunflag){VanillaRunOnDomReady}", 0);
}//]]>
</script>
</head>
<body>
<h1>Test</h1>
<div id="content"></div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment