开发者

how to know whether window is opened - PHP/Javascript?

There is a chat button, and whe开发者_StackOverflow中文版n users click on that chat button a new window will be opened and both the users can chat

how can i know, whether chat window is still open or not, when any of the user logged out from the application ?

and give a message, "chat window still open" and close the chat window...

name of the chat window : chat<?=$user->username?>...

I'm tracking when user logout, and other tries to send a message....then i'm giving him a message and close that window

code to open a window

win = window.open('../chat/index.php?user=<?=$uname->username?>','chatApp<?=$uname->username?>','width=400, height=500');

i need to close the chat window when users click on logout ? is this code right ?

echo "<script>win.close();</script>";


As long as the window that opens the pop up windows does not get reset [closed, refreshed, posted back] and kill the window object you can do something like the following to maintain the windows created.

  var winPop = {}

  function openPop( username, url ){
      if(winPop[username]){
          closePop(username);
      }
      winPop[username] = window.open( url );
  }

  function closePop( username ){
      if(winPop[username] && !winPop[username].closed){
          winPop[username].close();
          winPop[username] = null;
      }
  }

  function killAllPop(){
      for(var win in winPop){
          closePop(win);
      }
  }

If the window that opens it looses the window object you are out of luck with the parent closing it unless you do the clean up on onunload or onbeforeunload.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜