why doesn't this work?????

R

rynato

I have a function moveDiv(divID).

to test to see if the div has moved far enough:

if (new_left < 400)
{
the_timeout = setTimeout("moveDiv("myDiv");",10);
}

WORKS but this DOESN'T

if (new_left < 400)
{
the_timeout = setTimeout("moveDiv(divID);",10);
}

nor does this:

if (new_left < 400)
{
the_timeout = setTimeout("moveDiv("+divID+");",10);
}

nor does this:

if (new_left < 400)
{
the_timeout = setTimeout("moveDiv(this);",10);
}

how do I tell this statement to evaluate the argument 'divID'????????
The only way it works is if I give it the actual name of the div. I
have messed endlessly with the syntax and NOTHING works.
 
A

ASM

(e-mail address removed) a écrit :
I have a function moveDiv(divID).

to test to see if the div has moved far enough:

if (new_left < 400)
{
the_timeout = setTimeout("moveDiv("myDiv");",10);
}

WORKS

it would have not ! (it works with IE ?)

correct would have to be :

the_timeout = setTimeout("moveDiv('myDiv')",10);
but this DOESN'T

normal (see above about the ')
the_timeout = setTimeout("moveDiv(divID);",10);
nor does this:

not far from :)

the_timeout = setTimeout("moveDiv('"+divID+"')",10);
the_timeout = setTimeout("moveDiv("+divID+");",10);


2 solutions :
=============

1)
the_timeout = setTimeout("moveDiv('"+divId+"')",10);
2)
the_timeout = setTimeout(function(){ moveDiv(divId) },10);

Please see my answer to your other post "Passing a DIV ID ..."
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,608
Members
45,244
Latest member
cryptotaxsoftware12

Latest Threads

Top