Jump to content

problem with blur()


Nati323

Recommended Posts

hey, i read the ref about blur() method,

but its not work for me, you can see in the example here: http://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_win_blur

the code that given there need to blur the new window, but the blur() methos dosent work,

but if i do something like that:

<button onclick="myFunction()">Try it</button><button onclick="a()">Try it</button><script>var myWindow;function myFunction() {   myWindow = window.open("", "", "width=200, height=100");}function a () {    myWindow.blur();}</script>

this work, when i press the second button (after i open the window) the new window desappear, what is the problem?

Link to comment
Share on other sites

What happens when you click the second button is that you focus on the current browser window, causing it to go in front of the popup window.

Link to comment
Share on other sites

yes, but as you can see they wrote in the ref that it support in all broswers, so its wird :|

 

anyway, can you answer mi first que? i want to open popup, but that he will be in the background, i mean that the window will open, but you dont see him because he will be behind the opener (main) window, i see it in some site but i dont know how to do this...

Edited by Nati323
Link to comment
Share on other sites

Blur and focus methods aren't as reliable as they used to be. Once browsers started using tabs then those methods became less useful. Some browsers may still have those methods work like they used to, others might not. Try your code in different browsers to see how each of them work.

Link to comment
Share on other sites

Some advertisers used to make an ad window pop up and then hid it behind the main window. It was called "pop under" and browsers probably changed to prevent that from happening.

Link to comment
Share on other sites

They're doing it the same way that you're trying to do it, just with a few more tricks to try and get around the popup blocker. It doesn't work any better than anything else, my browser still blocks that popup.If you want to do it then you open the window and then blur it. Just be aware that the vast majority of browsers are going to block you from doing that because it's annoying.

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...