tags:

views:

190

answers:

2

I'm trying to focus an existing tab when the content reloads. The usual window methods don't seem to work.

Here's whats happening: On page_1 I have a link like...

<a href="page_2.html" target="page_2">Go to my other page</a>

If the tab doesn't exist, when the link is clicked it opens a new tab and takes focus. (Perfect)

If you then go back to page_1 and click the link again, it reloads the content in the existing tab (perfect) but doesn't focus (crap). I've tried the usual window.focus, $(window).focus methods on load with page_2 without luck.

Any recommendations?

A: 

Without using a framework you can put a script block at the bottom of your page that will run once the page loads. Because it is after your HTML you can be assured that the HTML is refers to is actually available.

The script can set the focus to the element you want.

Diodeus
The question is about focusing browser tabs, not elements.
David Dorward
+1  A: 

It is impossible.

David Dorward
And I'd say that's fortunate!
Ms2ger