View Full Version : Setting focus with frames

02-23-2005, 10:57 PM
Trying to figure out a way to set focus to a particular frame of a website
using javascript.

There are 3 frames: a top banner, a menu, and the main display.

What I want to do is when a link is clicked from the menu, to auto set the
focus to the main display. The link that is launched loads in the main display
as it shoud, but the focus is still remains at the menu frame (where the
click action was performed).


Willy Duitt
02-24-2005, 02:06 AM
Try: document.frames['main'].getElementsByTagName('body')[0].focus()

02-24-2005, 02:53 PM

Thanks for the reply.

Would this be used with the onload method?

Willy Duitt
02-24-2005, 02:58 PM
No, add it to the onclick event on the menu item that is clicked...

02-25-2005, 02:42 PM
Willy, tried it with the onlick and it didn't work.

I am going to revisit the code first to make sure that what existed first isn't
causing the issue.

Thanks for the support!