Jump to content

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


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 post
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 post
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 post
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 post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...