The problem is that to have this menu working you must add onload="clickMenu('menu')" to <body> tag, otherwise the menu won't work. But if I add this to "the body" other functions on the page won't work. Is there a way to activate the menu, without adding onload="clickMenu('menu')" to the body tag?
For obvious security reasons I don't click on posted links in forums like these. But is sounds like you are either accidentally 'blocking out' other onload functions when you add the clickMenu() to the body onload, and thus stopping the other functions from working, or clickMenu() itself is stopping other functions from working properly somehow.
If clickMenu() is interfering with other functions then it probably won't matter where or how you start clickMenu() and you would need to figure out what might be wrong with clickMenu().
no, didn't help, I guess it has something to do with the self javascript, someone knows of any other good "click" menus?
Should. Unless you have other libraries or pieces of code which use window.onload as well.
You could also try to attach new handlers:
Code:
function AttachEvent(obj,evt,fnc,useCapture){
if (!useCapture) useCapture=false;
if (obj.addEventListener){
obj.addEventListener(evt,fnc,useCapture);
return true;
} else if (obj.attachEvent) return obj.attachEvent("on"+evt,fnc);
else{
MyAttachEvent(obj,evt,fnc);
obj['on'+evt]=function(){ MyFireEvent(obj,evt) };
}
}
function MyAttachEvent(obj,evt,fnc){
if (!obj.myEvents) obj.myEvents={};
if (!obj.myEvents[evt]) obj.myEvents[evt]=[];
var evts = obj.myEvents[evt];
evts[evts.length]=fnc;
}
function MyFireEvent(obj,evt){
if (!obj || !obj.myEvents || !obj.myEvents[evt]) return;
var evts = obj.myEvents[evt];
for (var i=0,len=evts.length;i<len;i++) evts[i]();
}
AttachEvent(window,'load',function(){
clickMenu('menu');
//.. other functions, statements, etc.
},false);
No way. Should work by all means. You must have done another error... Without seeing your code I can not say which error. Have you removed onload=clickMenu('menu') from the BODY tag?
Post a link to a test page, to see what is all about.
Bookmarks