| Crashing IE Posted by: Jordan in Programming, JavaScript on Jun 17, 2008 |
IE still has a lot of bugs and I thought most were fixed in IE 7. This one bug I discovered while working with CCIT. I needed to include a div tag in the body for the TipLayer (the TipLayer is hidden until activated). I used the same DOM method as described here: Include a JavaScript file from a JavaScript file.
Here is the code I used:
In FireFox this works fine. Internet Explorer 6 or 7 throws an error "Internet Explor cannot open the internet site http://blog.codecall.net/. Operation aborted":
Which leads to this page (Page Cannot be displayed):
The problem is that I appended to the BODY element and my script wasn't a direct child of BODY. The fix is simple - either move your script to be a direct child (1st child) or BODY or use a different tag. In my case I needed the JavaScript be executed near the bottom so moving wasn't an option. I simply changed the tag.
Here is the code I used:
function insertDiv() {
var s = document.getElementsByTagName("body")[0];
var js = document.createElement("div");
js.setAttribute('id', 'TipLayer');
js.setAttribute('style', 'visibility:hidden;position:absolute;z-index:1000;top:-100' );
s.appendChild(js);
}
In FireFox this works fine. Internet Explorer 6 or 7 throws an error "Internet Explor cannot open the internet site http://blog.codecall.net/. Operation aborted":
Which leads to this page (Page Cannot be displayed):
The problem is that I appended to the BODY element and my script wasn't a direct child of BODY. The fix is simple - either move your script to be a direct child (1st child) or BODY or use a different tag. In my case I needed the JavaScript be executed near the bottom so moving wasn't an option. I simply changed the tag.
function insertDiv() {
var s = document.getElementsByTagName("a")[0];
var js = document.createElement("div");
js.setAttribute('id', 'TipLayer');
js.setAttribute('style', 'visibility:hidden;position:absolute;z-index:1000;top:-100' );
s.appendChild(js);
}
Set as favorite
Bookmark
Email This
Hits: 266
Trackback(0)
Write comment
