I have a web page with a javascript function inside window.onload that is not initialized ("undefined is not a function"), and I don't know why.
My code looks like this:
<script type="text/javascript">
function loadthis(e,pg) {
...
}
window.onload = function() {
loadthis(88,frm);
}
</script>
In almost all browsers, this works fine, but in some (the default Android browser and Dolphin) I get the following when I onloadtry to execute loadthis(88,frm):
Uncaught TypeError: undefined is not a function
I tried to define a function myonload()and call it from a tag bodywith the same behavior.
A page with full js code inside this .
EDIT # 1 There seems to be some inconsistencies in the browsers JS browser. For example, this code:
console.log(" ############## 1 ");
console.log(" ############## 2 "+frame);
console.log(" ############## 3 "+frame.src);
console.log(" ############## 4 "+frame.src.endsWith(pg));
gives this result:
**Uncaught TypeError: undefined is not a function**
, . frame.src. , .endsWith .
EDIT2: loadthis:
function loadthis(e,pg) {
clickbackground.trigger('click');
jQuery("body").trigger("click");
$('html').trigger('click');
var evt = e || window.event;
if (evt != 88 && evt !== "null") evt.preventDefault();
if (evt.button == 1) {
window.open(pg, '_blank');
} else {
if (frame && frame.src && frame.src.match(pg) != null) return;
if (evt !== 88) spinner.style.display = "block";
if (frame && frame.src) {
$.when($(frame).fadeOut(250)).promise().done(function() {
frame.remove();
frame.src = pg;
container.append(frame);
$(frame).fadeIn(600);
});
} else {
if (!frame) frame = document.getElementById("MainFrame");
$(frame).fadeOut(0);
frame.src = pg;
$(frame).fadeIn(600);
}
}
}