Nati323 Posted May 2, 2015 Share Posted May 2, 2015 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 More sharing options...
Ingolme Posted May 2, 2015 Share Posted May 2, 2015 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 More sharing options...
Nati323 Posted May 2, 2015 Author Share Posted May 2, 2015 ohh, hhh, so why the blur() method not working in the first code? from what i understand the methos suppose to disapear the new window, but its dosent work...? Link to comment Share on other sites More sharing options...
Ingolme Posted May 2, 2015 Share Posted May 2, 2015 Blur doesn't make it disappear, it should just stop being focused. That's different. Link to comment Share on other sites More sharing options...
Nati323 Posted May 2, 2015 Author Share Posted May 2, 2015 ok, so how can i get the result that the new window will disappear, and the first window will be shown again? in disappear i dont mean minimize Link to comment Share on other sites More sharing options...
Ingolme Posted May 2, 2015 Share Posted May 2, 2015 You mean to close the window? Call the .close() method: http://www.w3schools.com/jsref/met_win_close.asp Link to comment Share on other sites More sharing options...
Nati323 Posted May 3, 2015 Author Share Posted May 3, 2015 no, i dont mean close, i want that the window steel be open, but will be behind the main window. i try focus on the first window but its dosent work Link to comment Share on other sites More sharing options...
Nati323 Posted May 3, 2015 Author Share Posted May 3, 2015 also, the event onunload ( http://www.w3schools.com/jsref/event_onunload.asp ) dosent work for me when i close the window, why is that, in the ref they wrote that this event support in all brow's, i'm use chrome by the way...? Link to comment Share on other sites More sharing options...
justsomeguy Posted May 4, 2015 Share Posted May 4, 2015 What are you trying to do with the onunload event? Link to comment Share on other sites More sharing options...
Nati323 Posted May 6, 2015 Author Share Posted May 6, 2015 the example that i gave before ( http://www.w3schools.com/jsref/event_onunload.asp ) dosent work, its not show me the alert msg... Link to comment Share on other sites More sharing options...
justsomeguy Posted May 6, 2015 Share Posted May 6, 2015 It doesn't show it for me either using Opera. Not all browsers will run unload events. Link to comment Share on other sites More sharing options...
Nati323 Posted May 6, 2015 Author Share Posted May 6, 2015 (edited) 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 May 6, 2015 by Nati323 Link to comment Share on other sites More sharing options...
justsomeguy Posted May 6, 2015 Share Posted May 6, 2015 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 More sharing options...
Nati323 Posted May 6, 2015 Author Share Posted May 6, 2015 and why is that? more, if for example i want to open a new tab, but stay on the first tab? how can i do this? Link to comment Share on other sites More sharing options...
Ingolme Posted May 6, 2015 Share Posted May 6, 2015 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 More sharing options...
Nati323 Posted May 6, 2015 Author Share Posted May 6, 2015 thats want i want to do, and as you can see here: http://vidspot.net/0hig1wqyahp6 when you press on the "Continue to Video" button, its what happen, how they do that? Link to comment Share on other sites More sharing options...
justsomeguy Posted May 6, 2015 Share Posted May 6, 2015 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now