Reputation: 57343
I've got the following JavaScript on my web page...
64 var description = new Array();
65 description[0] = "..."
66 description[1] = "..."
...
78 function init() {
79 document.getElementById('somedivid').innerHTML = description[0];
80 }
81
82 window.onload = init();
In Microsoft Internet Explorer it causes the following error...
A Runtime Error has occurred.
Do you wish to debug?Line: 81
Error: Not implemented
Line 79 executes as expected.
If line 79 is commented out, it still throws the error.
If I comment out line 82, then the function does not execute and there is no error.
Upvotes: 4
Views: 6083
Reputation: 338208
Try to add an envent listener for 'load' instead, or use the declarative syntax <body onload="init()">
.
EDIT: Additionally, saying window.onload = init();
sets window.onload to the result of calling init()
. What you mean is window.onload = init;
(a lambda expression). This is bad practice still, as it overwrites other things that might be bound to window.onload
.
Upvotes: 1
Reputation: 17271
Try running it in FireFox with the FireBug plugin enabled. This will allow you to debug the javascript
Upvotes: 0
Reputation: 10692
To preserve any previously set onload functions try this
var prevload = window.onload;
window.onload = function(){
prevload();
init();
}
Upvotes: 2
Reputation: 6413
In addition to the onload fixes proposed here, also check to see if there are multiple elements with that ID, I believe IE will return a collection of all elements with that ID, in which case you would need to select the intended item out of the collection before accessing that property or ensure you are using unique IDs.
Upvotes: 0
Reputation: 140050
Shouldn't line 82 read:
window.onload = init;
When you do "init()" it's a call to a function that returns void. You end up calling that function before the page loads.
Upvotes: 13