[thelist] Javascript question

Sergey 'the Eych' Smirnov eych at ageofweb.ru
Thu Aug 15 02:30:00 CDT 2002


Greetings,

I have a problem passing certain parameter from one function to
another in Javascript. Here is the story.

I have a div on the page with id 'submenu'. On 'onmouseout' event i
want to hide it. Also i want to wait for several hundred milliseconds
before i do, so that the user will have time to point at it with a mouse
(this is a simple dhtml popup menu).

If i am right then the only way to ask the browser to wait is to use
window.setTimeout("function()", millisecs) call.

So i try the following:

>> [code quote]

function waitAndHide(id) {
  timer = window.setTimeout('hideDiv('+id+')', 250);
}

function hideDiv(id) {
  var element = getId(id);
  if (element) {
    (ns4) ? element.visibility = "hidden" : element.style.visibility = "hidden";
  }
  return false;
}

>> [/code quote]

Now, id that is passed to waitAndHide is not an object - it is just a
div id - a string. With getId() i am getting an object from 'id' and
then i use it.

But! For some strange reason id is not passed to hideDiv. It is
defined and works ok inside waitAndHide() but it is undefined in
hideDiv(). What might be the problem? What am i missing?

Also, for another strange reason i found out that IE 6.0 thinks that
'id' is already an object inside waitAndHide and i can get id from it
with 'id.id'. While Mozilla doesn't think that 'id' is an object and i
just can't make it pass 'id' correctly to hideDiv.

Any help will be appreciated.

---
Sergey "the Eych" Smirnov
One of the Stuffed Guys
http://www.stuffedguys.com




More information about the thelist mailing list