Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > click() function does not have same effect as real click (IE 6)

Reply
Thread Tools

click() function does not have same effect as real click (IE 6)

 
 
Lazlo Woodbine
Guest
Posts: n/a
 
      05-14-2004
I'm trying to implement a dynamic menu using CSS/DHTML/JavaScript. The
menu bar is implemented as hyperlinks so I can use the :hover :active
etc. pseudo-styles.

When moving from one item to another on the menu bar I want to
simulate the user clicking on the menu bar item they've just moved
onto, so the adjacent menu drops down automatically.

So I have something like this:

function MenuBarItemMouseover(menuBarItem)
{
menuBarItem.click();
}

to simulate the user clicking on the adjacent menu.

However it seems the previous menu bar item stays in the 'active'
state and the item that has been moved onto remains in the 'hover'
state.

The css styles are defined in the order: link, visited, hover, active,
and in any case, it works fine if you actually do a mouse click on a
different menu bar item. It seems the programmatic click is not the
same.

Is there anyway of forcing the previous link to 'normal' and the new
link to 'active' using JavaScript? Or is there some other way of
simulating a mouse click?
 
Reply With Quote
 
 
 
 
Lazlo Woodbine
Guest
Posts: n/a
 
      05-14-2004

It turns out the answer is very simple. ĦHurrah!

You need to call focus() on the item that you wish to click, since
click() itself does not change the focus (on IE 6), and hence the
active status of the 2nd item doesn't change:

function MenuBarItemMouseover(menuBarItem)
{
menuBarItem.focus();
menuBarItem.click();
}

On 14 May 2004 11:00:10 -0700, http://www.velocityreviews.com/forums/(E-Mail Removed) (Lazlo Woodbine)
wrote:

>I'm trying to implement a dynamic menu using CSS/DHTML/JavaScript. The
>menu bar is implemented as hyperlinks so I can use the :hover :active
>etc. pseudo-styles.
>
>When moving from one item to another on the menu bar I want to
>simulate the user clicking on the menu bar item they've just moved
>onto, so the adjacent menu drops down automatically.
>
>So I have something like this:
>
>function MenuBarItemMouseover(menuBarItem)
>{
> menuBarItem.click();
>}
>
>to simulate the user clicking on the adjacent menu.
>
>However it seems the previous menu bar item stays in the 'active'
>state and the item that has been moved onto remains in the 'hover'
>state.
>
>The css styles are defined in the order: link, visited, hover, active,
>and in any case, it works fine if you actually do a mouse click on a
>different menu bar item. It seems the programmatic click is not the
>same.
>
>Is there anyway of forcing the previous link to 'normal' and the new
>link to 'active' using JavaScript? Or is there some other way of
>simulating a mouse click?


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Does os.getcwd() and os.curdir have the same effect ? iMath Python 4 09-27-2012 06:26 AM
Why can't I call a function which does what it does if a click on theheader of a column? Stefan Mueller Javascript 23 12-14-2009 06:07 AM
click click click Andy Morrison Computer Support 7 12-20-2007 06:50 AM
2 PIX Same COnfig, though 1 not connected to 'real' outside? Does not work? Scott Townsend Cisco 3 03-23-2006 04:43 PM
call any usa REAL telephone number from the internet at pulver freeworld for .06 per minute - have your own real fone # for $10 month!! ucallvoip@yahoo.com VOIP 0 06-09-2004 01:41 AM



Advertisments