I am using two open source scripts one for Menu (fsmenu) and other for DragnDrop (wz_dragdrop). they both register their events to onload. it is working fine in firefox and mozilla but when I try to run the page in IE it only registers one binding i.e. registered last. Is there any way I can run both the script on IE. or any workarounds to register two events on load. thanks in advance.
You can try with something like this: attachOnloadEvent(myOnloadFunc1); // attach func function to window onload event (crossbrowser compatible) function attachOnloadEvent(func) { if(typeof window.addEventListener != 'undefined') { // moz, saf1.2, ow5b6.1 window.addEventListener('load', func, false); } else if (typeof document.addEventListener != 'undefined') { // MSN/OSX, op7.50, saf1.2, ow5b6.1 document.addEventListener('load', func, false); } else if (typeof window.attachEvent != 'undefined') { // ie5.0w, ie5.5w, ie6w window.attachEvent('onload', func); } else { // all other browsers if (typeof window.onload == 'function') { var oldonload = onload; window.onload = function() { oldonload(); func(); }; } else { window.onload = func; } } } Code (markup):
Create one function that calls your two functions and call it in onload. It seems pretty cut and dry to me.