I have this the javascript work perfectly in chrome but not work on IE7:
The click of id icsave , not work. Nothing happens, icsave save the page normaly
window.onload = function() {
if ($('#MODE').val() != 'U') {
$('#MOD_BY_JS').val( % 1);
clik('#ICSave')
}
};
function clik(element) {
try {
document.getElementById(element).click();
}
catch (e) {
var evt = document.createEvent("MouseEvents");
evt.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
var cb = document.getElementById(element);
cb.dispatchEvent(evt);
}
};
window.onloadmay not get executed for a number of reasons.window.onloadonly fires after all resources have loaded.window.onloadMy suggestion to you is that since you’re using jQuery, use either:
or if you actually need
onloadFor your example I would recommend using the
$(document).ready(...)method as it looks to me your script will work as soon as the dom is ready, which is when thereadyevent fires.