I use the code below to open a new browse开发者_开发知识库r.
var winHndle = window.open(url,'myWindow');
winHndle.focus();
I don't mind if user settings come into play and it opens in a new window or tab.
My issue is I want the focus to change if the window/tab already exists. I can see the handle works fine - it refreshes, but focus doesn't change to that tab.
I keep seeing posts saying use focus()
, but it just doesn't work.
Without mucking around with user settings only IE and safari seem to open in a new window with this code. I just download and installed most recent versions of firefox, opera, safari and chrome - already had IE 8. So for most browsers my focus code is useless :-(
FYI...I use "myWindow" so the next time I open the window it opens/refreshes the same instance if it's still there.
Why don't you just use this:
<a href="http://www.example.com/" target="_blank">Click here to open in new window/tab</a>
I use that all the time and it works. It always focuses on the new window opened.
I hope this helps you.
精彩评论