I'm currently having a problem with a script that calls getElementByID
in Internet Explorer 11 (and presumably older versions). It works fine in Edge, Chrome, FF, etc. But in IE, the divs don't appear and in the console I get the error:
SCRIPT5007: Unable to set property 'visibility' of undefined or null reference
Essentially, there are four hidden divs and the script reveals each one in turn with a few seconds gap between them.
The function is called by the body tag:
<body onload="displayBlocks()">
Html for the divs is:
Some Text
<div id="text_box_2" class="tb">
Some Text
</div>
<div id="text_box_3" class="tb">
Some Text
</div>
<div id="text_box_4" class="tb">
Some Text
</div>
And the script is:
i = 0;
function displayBlocks() {
if (i < 4) {
alert
setTimeout(function() {
showBlock(i);
}, 3000);
}
}
function showBlock(blockN) {
if (blockN == 0) {
item = document.getElementById("text_box_1");
item.style.visibility = "visible";
}
if (blockN == 1) {
item = document.getElementById("text_box_2");
item.style.visibility = "visible";
}
if (blockN == 2) {
item = document.getElementById("text_box_3");
item.style.visibility = "visible";
}
if (blockN == 3) {
item = document.getElementById("text_box_4");
item.style.visibility = "visible";
}
i++;
displayBlocks();
}
}
Any ideas on why this is happening would be much appreciated.