Jump to content

Object is required


adrianv

Recommended Posts

I get an "Object is required" error in:

<a href="url" onMouseover="setTimeout('cssdropdown.dropit(this,event,\'dropmenuArt\')',400)">urltext</a>

the code works great outside the setTimeout

onMouseover="cssdropdown.dropit(this,event,'dropmenuArt')"

although it seams that the setTimeout is also working because i get the error only after the 400ms delay...it might be a syntax problem...please advise

Link to comment
Share on other sites

no, the function receives 3 parameters: 1) this 2) event 3) the menu nameas i said, it works when outside the setTimeout procedure.and just to make sureĀ  i tested your suggestion, didn't work :)

Sorry! :)I think setTimeout is just OK now, but move it inside of Your function,and call function straight with onmouseover.
Link to comment
Share on other sites

The setTimeout function can not handle executing a function as one of its parameters if the function has arguments. That's probably your problem. :)

Link to comment
Share on other sites

The setTimeout function can not handle executing a function as one of its parameters if the function has arguments. That's probably your problem. :)

I don't think that is the problem, i see it in a lot of places.I can't seem to find a free css drop down menu that have a delay before it opens, they all have a delay after though.... :)
Link to comment
Share on other sites

Try this, i think the nested quotes might have been incorrect

onMouseover="setTimeout('cssdropdown.dropit(this,event,\"dropmenuArt\")',400)">urltext</a>

If it doesn't work post link or full code.

Link to comment
Share on other sites

Try this, i think the nested quotes might have been incorrect
onMouseover="setTimeout('cssdropdown.dropit(this,event,\"dropmenuArt\")',400)">urltext</a>

If it doesn't work post link or full code.

the nested quotes are fine, if i use " then i get the "undetemined string" error... because of the onMouseover quotes.here is the full code i use:chrome drop down menu from dynamic drive
Link to comment
Share on other sites

This is a bad coding practice but I feel I must suggest it anyways, to see if this is the problem.Try removing all the quotes on the dropmenuArt and see what happens. Most likely it will not be able to find the object either, I think it might be worth a try. Also, I think that Chocolate570 is correct. Just because you have seen it done before doesn't mean that it will work here. Try to open the .js file and perhaps use the delayhidemenu() function they use to delay showing it as well.

dropit:function(obj, e, dropmenuID){if (this.dropmenuobj!=null) //hide previous menuthis.dropmenuobj.style.visibility="hidden"this.clearhidemenu()if (this.ie||this.firefox){obj.onmouseout=function(){cssdropdown.delayhidemenu()}this.dropmenuobj=document.getElementById(dropmenuID)this.dropmenuobj.onmouseover=function(){cssdropdown.clearhidemenu()}this.dropmenuobj.onmouseout=function(){cssdropdown.dynamichide(e)}this.dropmenuobj.onclick=function(){cssdropdown.delayhidemenu()}this.showhide(this.dropmenuobj.style, e, "visible", "hidden")this.dropmenuobj.x=this.getposOffset(obj, "left")this.dropmenuobj.y=this.getposOffset(obj, "top")this.dropmenuobj.style.left=this.dropmenuobj.x-this.clearbrowseredge(obj, "rightedge")+"px"this.dropmenuobj.style.top=this.dropmenuobj.y-this.clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+1+"px"}

Link to comment
Share on other sites

Thanks Nakor for your quick response.i tried it without any quotes, still no luck.I also tried a few days ago to convert the delayhidemenu() function to a delayshowmwnu() but i keep getting errors. could you please tell me where exactly to use the delayshowmwnu() with the correct syntax?i mostly write code for server side and i'm practically clueless as to client side script so i would realy appriciate the help guys.

Link to comment
Share on other sites

I attempted to reverse some of the javascript functions that the file is calling. Try and make these changes to the js file and see what happens.

...disappeardelay: 250, //set delay in miliseconds before menu disappears onmouseoutappeardelay: 400, // set delay in milliseconds before menu apears onmousein...dropit:function(obj, e, dropmenuID){if (this.dropmenuobj!=null) //hide previous menuthis.dropmenuobj.style.visibility="hidden"this.clearhidemenu()if (this.ie||this.firefox){obj.onmouseout=function(){cssdropdown.delayhidemenu()}this.dropmenuobj=document.getElementById(dropmenuID)this.dropmenuobj.onmouseover=function(){cssdropdown.dynamicshow(e)}this.dropmenuobj.onmouseout=function(){cssdropdown.dynamichide(e)}this.dropmenuobj.onclick=function(){cssdropdown.delayhidemenu()}this.showhide(this.dropmenuobj.style, e, "visible", "hidden")this.dropmenuobj.x=this.getposOffset(obj, "left")this.dropmenuobj.y=this.getposOffset(obj, "top")this.dropmenuobj.style.left=this.dropmenuobj.x-this.clearbrowseredge(obj, "rightedge")+"px"this.dropmenuobj.style.top=this.dropmenuobj.y-this.clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+1+"px"}},...dynamicshow:function(e){var evtobj=window.event? window.event : eif (this.ie&&!this.dropmenuobj.contains(evtobj.toElement))this.delayshowmenu()else if (this.firefox&&e.currentTarget!= evtobj.relatedTarget&& !this.contains_firefox(evtobj.currentTarget, evtobj.relatedTarget))this.delayshowmenu()},...delayshowmenu:function(){this.delayshow=setTimeout("cssdropdown.dropmenuobj.style.visibility='visible'",this.appeardelay)},

Link to comment
Share on other sites

the minute i hit the replay to say that i have made some progress i sow your post!so i tried it, but it didn't work.my changes are:

dropit:function(obj, e, dropmenuID){	if (this.dropmenuobj!=null) //hide previous menu	this.dropmenuobj.style.visibility="hidden"	this.clearhidemenu()	if (this.ie||this.firefox){ Ā obj.onmouseout=function(){cssdropdown.delayhidemenu()} Ā obj.onmouseover=function(){cssdropdown.delayshowmenu()} // <-----NEW CODE 	Ā this.dropmenuobj=document.getElementById(dropmenuID) 	Ā this.dropmenuobj.onmouseover=function(){cssdropdown.clearhidemenu()} 	Ā this.dropmenuobj.onmouseout=function(){cssdropdown.dynamichide(this.ze)} 	Ā this.dropmenuobj.onclick=function(){cssdropdown.delayhidemenu()} 	Ā this.showhide(this.dropmenuobj.style, e, "visible", "hidden") 	Ā this.dropmenuobj.x=this.getposOffset(obj, "left") 	Ā this.dropmenuobj.y=this.getposOffset(obj, "top") 	Ā this.dropmenuobj.style.left=this.dropmenuobj.x-this.clearbrowseredge(obj, "rightedge")+"px" 	Ā this.dropmenuobj.style.top=this.dropmenuobj.y-this.clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+1+"px"	}},------------------dynamicshow:function(e){var evtobj=window.event? window.event : eif (this.ie&&!this.dropmenuobj.contains(evtobj.toElement))this.delayshowmenu()else if (this.firefox&&e.currentTarget!= evtobj.relatedTarget&& !this.contains_firefox(evtobj.currentTarget, evtobj.relatedTarget))this.delayshowmenu()},delayshowmenu:function(){this.delayshow=setTimeout("cssdropdown.dropmenuobj.style.visibility='visible'",this.showdelay)},clearshowmenu:function(){if (this.delayshow!="undefined")clearTimeout(this.delayshow)}

that almost does the job! it delays the showmenu but after the delay the menu appears anyway, and also after a few show hide it gets stuck...here is an example link: My Webpagehere

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...