开发者

Alternative to blur() for setting window focus?

开发者 https://www.devze.com 2023-02-14 03:48 出处:网络
I am using a little bit of Javascript to set the focus of a window to the background.I am asking a user if they want to take a survey.If so, the survey window should fall behind the active window so t

I am using a little bit of Javascript to set the focus of a window to the background. I am asking a user if they want to take a survey. If so, the survey window should fall behind the active window so they can continue to surf the sit开发者_高级运维e unabated. The JS works fine, except for in Chrome (and probably Safari).

Here's the JS:

window.onload = function()
{
  self.blur();
};

Is there a better way to do this that has better browser acceptance?


To my knowledge, there is no standard or reliable way to force the window manager to position a popup window below its parent on all platforms.

If you're into unobtrusive surveys, you might want to consider implementing something like StackOverflow's notification bar, and opening your popup window in the foreground only if the user interacts with that element.


Looks like you have the survey window in front of another window, and want it to go behind that window if user elects to take the survey. Try this:

<BODY onLoad="self.blur()">
0

精彩评论

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

关注公众号