开发者

How to open a new window (or in a tab), but not give it focus

I have a function that I want to open up a URL in a new tab on a click event, but not give that ta开发者_JAVA百科b focus. Is this possible with javascript?


You can't steal focus from a newly opened window. It's a security feature preventing sites from "taking control" of your browser. That would be a browser configuration setting.

As far as "hiding" focus from a popup, you might be thinking of what's called "PopUnder". Basically you use window.open() and set the option _blank and the paramater alwaysLowered, but it will not work gracefully for an average website. It requires you to have a signed script and take advantage of the Netscape Security PrivilegeManager, like this:

netscape.security.PrivilegeManager.enablePrivilege("UniversalPreferencesRead UniversalBrowserAccess"); // etc...

Sorry bro :)


You can attempt to open a new window, then set focus back to the current window. However, user settings may make this impossible, or it might already be the default behaviour.

Pop–unders are used by some web sites probably to disassociate the web site from the window (i.e. so you don't know where it came frome). So they are assuming a certain naivety on behalf of the user. They are considered spam and treated with the same contempt.

If you outline what it is you are trying to achieve using a pop–under, you might get advice on better ways of doing it. Or not. :-)


To my knowledge it is impossible bro.Since the user's browser Settings will conflict with your logic

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜