Jump to content

Do new pages (opened with _blank) always get focus?


L.Adlon

Recommended Posts

If I have a hyperlink to another page, and have it set with target="_blank", does the newly opened page always get focus (...or, maybe I'm using that term wrong... will it always open up and be displayed on top of the previous page)?

 

I always assumed it did, and it always seemed to. But, as I've been working on one of my sites today, and tested one of the links, I think it opened the new page, but kept focus/display on the previous page. So, I'm wondering if this is ever possible, and if so, what can be done to assure the new page is always displayed.

 

This was on Win7, BTW.

 

 

[Additional note] Ya, it just happened again. Seems random. I have a link to a YouTube page (set to target="_blank"). I clicked on it. It opens a new browser page (YouTube page), plays the video, but then the tab for the previous window suddenly gets 'focus' (sorry if that's the wrong term), and the page I came from is displayed, rather than the newly opened YouTube one. I tried it again, and it worked fine (new page stayed on top). What's the deal there?!

Edited by L.Adlon
Link to comment
Share on other sites

I'm trying to find out, but the specification does not seem to say anything about whether the target window or frame will be focused.

 

If it says nothing, then you can't count on all the browsers behaving the same way. I think it's likely that the user can choose whether to focus new windows or not in the browser settings.

Link to comment
Share on other sites

  • 2 weeks later...

Ya, but the weird thing is, on my browser, the behavior seemed random. Sometimes, the newly opened window remained on top (new browser window was on top of the first one). On other (seemingly random) occassions, the new browser window would open, the content displayed, but then the first window would suddenly go on top of it again (within a second or so). I've never seen that kind of behavior before, as the new window (previously) always displayed on top, and never switched back to the first one again.

 

Maybe I'm using the term 'focus' the wrong way, as I think that applies more to which ELEMENT on the screen currently is 'highlighted'/active.

 

Whatever the case, my main concern is that (seemingly randomly) the first browser window suddenly 'goes on top of' the newly opened second browser window. If it IS in fact a browser setting, why would it only do it sometimes?

Link to comment
Share on other sites

I can't tell why it would work differently at random times. Focus is the proper word for when a window is currently selected by the operating system or when a tab is currently in front.

 

The window object has a focus() method (and a blur()) method, but can only be called by another window that created the current window.

Link to comment
Share on other sites

Yep, I can't say I've ever seen this kind of thing before... Normally, it just would open up the new window, and that would be on top of the old one.

 

I thought maybe it was some weird cache/buffer reaction, but I don't know.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...