By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,945 Members | 1,328 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,945 IT Pros & Developers. It's quick & easy.

why doesn't this work?????

P: n/a
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.

Dec 4 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
ry****@gmail.com wrote:
>
if (new_left < 400)
{
the_timeout = setTimeout("moveDiv(divID);",10);
}

if (new_left < 400) {
the_timeout = setTimeout("moveDiv('"+divID+"');",10);
}
---------------------------------------------------------------------------
http://www.hunlock.com -- Permanently under construction (And proud of it!)
$FA
Dec 4 '06 #2

P: n/a
jesus christ.

thank you. you saved my sanity.

pcx99 ha scritto:
ry****@gmail.com wrote:

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


if (new_left < 400) {
the_timeout = setTimeout("moveDiv('"+divID+"');",10);
}
---------------------------------------------------------------------------
http://www.hunlock.com -- Permanently under construction (And proud of it!)
$FA
Dec 4 '06 #3

P: n/a
ASM
ry****@gmail.com 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 ..."
--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
Dec 4 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.