Author Topic: Window.open Blocked  (Read 721 times)

Offline Glenugie

  • Level 10
  • *
  • Posts: 64
  • Reputation: +0/-0
    • View Profile
    • The Land of Ennui
Window.open Blocked
« on: October 19, 2009, 04:19:46 AM »
Hello Again,
I'm writing a bit of code that will update the user's online status if they close the browser. I'm using:
Code: [Select]
<body onUnload="window.open('BrowserClose.php','Browser Close','width=1,height=1,status=no')">But the browser blocks this as a popup, the only function of BrowserClose.php is to update the user's status in a database:
Code: [Select]
$LoginUpdate = mysql_query("UPDATE Users SET Online='N' WHERE username='$username'");If I set the popup blocker to allow from my page, the code runs, so there isn't a problem with the code, it's just getting it to run when a popup blocker is active. Opening a popup probably isn't the neatest way to achieve my goal, and it isn't practical for me to ask everyone who visits my game to turn off their popup blocker, so is there a way around this problem?

*Chants Under his breath* 'Don't say AJAX, don't say AJAX' :)

Thanks in advance,

~Glenugie~

Offline raestlyn

  • Level 29
  • **
  • Posts: 464
  • Reputation: +9/-5
    • View Profile
Re: Window.open Blocked
« Reply #1 on: October 19, 2009, 05:32:37 AM »
Well, making an AJAX call is easiest solution.
You can also try window.location instead of window.open, like this:
Code: ( NOT TESTED) [Select]
<body onUnload="window.location('BrowserClose.php')">


I can send you pics of my cocks if you want reference.


Offline Glenugie

  • Level 10
  • *
  • Posts: 64
  • Reputation: +0/-0
    • View Profile
    • The Land of Ennui
Re: Window.open Blocked
« Reply #2 on: October 19, 2009, 01:16:37 PM »
I had a bad feeling AJAX might come into it, hopefully not so much of a bother to me as last time?

I'll look up some tutorials in a little while, see what I can dig up. Window.location didn't really work.

~Glenugie~

Offline Glenugie

  • Level 10
  • *
  • Posts: 64
  • Reputation: +0/-0
    • View Profile
    • The Land of Ennui
Re: Window.open Blocked
« Reply #3 on: October 19, 2009, 01:28:36 PM »
Another question, while I'm on the topic of windows. I have items which all have a picture, when the picture si clicked, it opens a window with detailed information about the item. I want to be able to open multiple windows like this, but it always overwrites the previous window when opening a window:
Code: [Select]
<img src="H1.jpg" onclick="window.open('description.php?ID=<?echo $HatID;?>','Description','width=250,height=200')" class=hand border=0>
How would I go about fixing this?

~Glenugie~

Offline Nox

  • Level 35
  • **
  • Posts: 768
  • Reputation: +12/-2
    • View Profile
Re: Window.open Blocked
« Reply #4 on: October 19, 2009, 01:31:24 PM »
1)
Depending on amount of JS you plan to create you might consider using jQuery library, it also makes AJAX much easier
(but if most of your JS is already finished then it wouldn't be appropriate linking a library and then using it in 2% of scripts)

2)
Try changing the name of the window
Meet us at an IRC irc.freenode.net #bbg as well
https://vimeo.com/36579366 (a must-watch) | Join BOINC - no longer a hype, but you can help never the less

Offline Glenugie

  • Level 10
  • *
  • Posts: 64
  • Reputation: +0/-0
    • View Profile
    • The Land of Ennui
Re: Window.open Blocked
« Reply #5 on: October 19, 2009, 01:53:45 PM »
Thanks, worked just fine :)

~Glenugie~

ST-Mike

  • Guest
Re: Window.open Blocked
« Reply #6 on: October 21, 2009, 06:21:21 PM »
Admins have ignored my deletion request - if you're not going to delete my account then don't have the option there please.
« Last Edit: March 15, 2011, 08:01:19 PM by None »

Offline Nox

  • Level 35
  • **
  • Posts: 768
  • Reputation: +12/-2
    • View Profile
Re: Window.open Blocked
« Reply #7 on: October 22, 2009, 01:08:12 AM »
Yeah, I think ST-Mike is right and I use the same what he suggested

Additionaly ... I realised now that - are you aware that the event "unload" is not only fired when closing browser but on every page unload? Meaning if they click any link/back/forward/refresh the event will trigger as well ... so it might result in incorrect but surely in poor performance behaviour
Meet us at an IRC irc.freenode.net #bbg as well
https://vimeo.com/36579366 (a must-watch) | Join BOINC - no longer a hype, but you can help never the less

Offline Glenugie

  • Level 10
  • *
  • Posts: 64
  • Reputation: +0/-0
    • View Profile
    • The Land of Ennui
Re: Window.open Blocked
« Reply #8 on: October 22, 2009, 06:35:05 AM »
Right, point noted, I've set up the method you've suggested.

Never mind, solved it :)

~Glenugie~
« Last Edit: October 23, 2009, 06:09:10 AM by Glenugie »

 


SimplePortal 2.3.3 © 2008-2010, SimplePortal