Setting focus to a tab

35 views
Skip to first unread message

Claus Mygind

unread,
Aug 30, 2007, 12:18:55 PM8/30/07
to
If this is the wrong news group to post this question, please direct me the
proper news group so I can repost.

The following code works well when I open or want to set focus to a
subWindow. I would like to set focus to a specific tab in the same manner.
For example a link in tab1 either opens a new tab is it does not exists or
if it is already created set focus to that tab. How can this code be
reworked to do that?

Thank you in advance
Claus

var dWindow;
function doDetail(cUrl)
{
if (!dWindow || dWindow.closed) {
dWindow = window.open(cUrl,"subwin");
} else {
// window is already open, so bring it to the front
dWindow.focus();
}
}

Stanimir Stamenkov

unread,
Aug 31, 2007, 7:26:32 AM8/31/07
to
Thu, 30 Aug 2007 11:18:55 -0500, /Claus Mygind/:

> If this is the wrong news group to post this question, please direct me the
> proper news group so I can repost.

As I don't think this is related to HTML I'm cross-posting it to
mozilla.dev.web-development (followup-to set).

> The following code works well when I open or want to set focus to a
> subWindow. I would like to set focus to a specific tab in the same manner.
> For example a link in tab1 either opens a new tab is it does not exists or
> if it is already created set focus to that tab. How can this code be
> reworked to do that?
>
> Thank you in advance
> Claus
>
> var dWindow;
> function doDetail(cUrl)
> {
> if (!dWindow || dWindow.closed) {
> dWindow = window.open(cUrl,"subwin");
> } else {
> // window is already open, so bring it to the front
> dWindow.focus();
> }
> }

I guess the window.focus() function just activates the top-level
window the document frame is in. There may are practical reasons
for this behavior (in the case the window is opened in a tab) but I
can't point any at the moment.

--
Stanimir

Reply all
Reply to author
Forward
0 new messages