I have used the following function in my javascript code:
function k_addLoadEvent() {
var oldonload = window.onload;
if (typeof window.onload != 'function') {
alert('in');
window.onload = function(){alert('hi');}
} else {
window.onload = function() {
if (oldonload) {
oldonload();
}
someFunction();
}
}
}
k_addLoadEvent();
The line window.onload = function(){alert('hi');}
is not working in IE 9 and below.
The alert alert('in')
is working but not the alert('hi')
. I do not see any error in the console.
What am I missing in the code?