/    Sign up×
Community /Pin to ProfileBookmark

DHTML setTimeout Error

Hi.

I want to create a menu witch will slide submenus. The menu us based on ul li elements.

I have the following code:

[COLOR=Blue]

function menu(el, level)
{
var interval

this._parent = el;
this._ul = this._parent.getElementsByTagName(“ul”).item(0)
this._level = level;

this.stPos = this._ul.offsetHeight
this.topPos = 20 – this.stPos

this._parent.onmouseover=function() {
this.show()
}

this._parent.onmouseout=function() {
}

}

menu.prototype.show = function show()
{
var width = this._ul.offsetWidth
var height = this._
ul.offsetHeight

if (this.stPos!=0)
{
this.stPos=this.stPos-5
this.topPos=this.topPos+5
this._ul.style.clip=”rect(” + this.stPos + “px, ” + width + “px, ” + height + “px, ” + ” 0px)”
this._ul.style.top=this.topPos + ‘px’
this.interval = setTimeout(“[COLOR=Red]show()[/COLOR]”, 100)
}

}

var el = document.getElementById(“xx”);
var menu1 = new menu(el,1);
menu1.show();

[/COLOR]

I get this:

[COLOR=Red]Error:
name: ReferenceError
message: Statement on line 1: Reference to undefined variable: show
Backtrace:
Line 1 of unknown script
show();[/COLOR]

I tried this.show() but same result.

Can anyone help me?

Thnaks!

Alin.

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@phpnoviceFeb 21.2006 — This does not lend itself to multiple overlapping occurrences, but... You can set up a global variable and assign an object reference to it for use with your timer.

currmenu = this;

this.interval = setTimeout("currmenu.show()", 100)
×

Success!

Help @Alinu spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.21,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...