javascript know whether a window is opened or not

Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Reply

Join Date: Jun 2009
Posts: 1
Reputation: urvenkatg is an unknown quantity at this point 
Solved Threads: 0
urvenkatg urvenkatg is offline Offline
Newbie Poster

javascript know whether a window is opened or not

 
0
  #1
Jun 3rd, 2009
Hi

I am doing a chating application.I want to know whether a window is opened or not.
This is the code i am using to open a window.

  1. var title='Chat_'+userId+"_"+selectedUserId;
  2.  
  3. var url="OneToOneChat.aspx?FromUserId="+userId+"&FromUserName="+userName+"&ToUserId="+selectedUserId+"&ToUserName="+selectedUserName;
  4.  
  5. window.open(url,title,'width=410,height=400,toolbar=no,menubar=no,scrollbars=no,status=yes',false);

later i trying whether the window is already opened or not.

  1. var win='Chat_'+userId+"_"+selectedUserId;
  2. if(win.closed)
  3. {
  4. }
  5. else
  6. {
  7. }
for win.closed it is giving javascript error like "closed is null or not an object".

I am using IE7.

Please h on this.

Thanks in Advance

Venki
Last edited by peter_budo; Jun 3rd, 2009 at 1:16 pm. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 11
Reputation: ankitjain_dce is an unknown quantity at this point 
Solved Threads: 1
ankitjain_dce ankitjain_dce is offline Offline
Newbie Poster

Re: javascript know whether a window is opened or not

 
0
  #2
Jun 6th, 2009
Hi,
You might want to try (window.opener.closed)

Thanks.
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 11
Reputation: ankitjain_dce is an unknown quantity at this point 
Solved Threads: 1
ankitjain_dce ankitjain_dce is offline Offline
Newbie Poster

Re: javascript know whether a window is opened or not

 
0
  #3
Jun 6th, 2009
Oh i think problem might be u r opening the window w/o assigning it to a variable.....fifth line above should be:
var win=window.open(url,title,'width=410,height=400,toolbar=no,menubar=no,scrollbars=no,status=yes',false);

There is no need for new win var in the second javascript code and u can directly for win.closed.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC