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.

var title='Chat_'+userId+"_"+selectedUserId;

var url="OneToOneChat.aspx?FromUserId="+userId+"&FromUserName="+userName+"&ToUserId="+selectedUserId+"&ToUserName="+selectedUserName;

                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.

var win='Chat_'+userId+"_"+selectedUserId;
if(win.closed)
{
}
else
{
}

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

Hi,
You might want to try (window.opener.closed)

Thanks.

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.