Menu
Hi All,
I have one problem of knowing how to know whether window already exists.
My application has some links and on clicking them opens in new popup window. Some of them has forms to fill.
For Example if user clicks
Link1 which opens in new popup window and has form to fill.
Similarly Link2 – opens in 2nd popup window.
If user again tries to click Link1 then it should just focus the already opened popup for that link so that user will not use any data while filling the form.
Can anyone help me in fixing this issue?
Thanks.
Pradeep Peddi.
I have one problem of knowing how to know whether window already exists.[/QUOTE]
if (type == "console" || type == "fullscreen")
{
tools = "resizable,toolbar=no,location=no,scrollbars=no,width="+strWidth+",height="+strHeight+",left=0,top=0";
}
// Here is what I am doing for checking already opened ppups
if(windowObject[winName+uniqueIdArray[url]]!=null)
{
alert('window is already opened for this link and will set the focus to that window');
windowObject[winName+uniqueIdArray[url]].focus();
}
else
{
alert('New window will be opened for this link');
windowObject[winName+uniqueIdArray[url]] = window.open(url, winName+uniqueIdArray[url], tools);
windowObject[winName+uniqueIdArray[url]].focus();
}
//look for parameters
attribs = this.rel.split(" ");
if (attribs[1] != null)
{ t = attribs[1];
}
if (attribs[2] != null)
{
width = attribs[2];
}
if (attribs[3] != null)
{
height = attribs[3];
}
// --------call the popup script----------
popUpWin(this.href,t,width,height);
//cancel the default link action if pop-up activated
if (window.event)
{
window.event.returnValue = false;
window.event.cancelBubble = true;
}
else if (e)
{
e.stopPropagation();
e.preventDefault();
}
//adding string value after '.' as uniqueId to the map which will be used as unique Window name
uniqueIdArray[popups[i].href]=uniqueId;
alert('internal popup | '+popups[i].href+' | with uniqueId '+uniqueIdArray[popups[i].href]);
}
// ----------attach popup behaviour--------
popups[i].onclick = doPopUp;
// add info to title attribute to alert fact that it's a pop-up window
popups[i].title = popups[i].title + "Opens in a new window";
}
}
if we remove last two lines then it will be just empty window, right?[/QUOTE]
var myPtr1 = window.open('', winName, tools);
if(myPtr1
&& myPtr1[winName]
&& myPtr1[winName].name
&& myPtr1[winName].name == winName)
{
myPtr1.focus();
}
else
{
myPtr1.location.href = url;
}
<script type="text/javascript">
var top[top.name] = {name:top.name};
</script>
... this statement..
var myPtr1 = window.open('', winName, tools);
opens a window with empty URL.
If a window with that name already exists the above statement will reload a new page into that window with empty URL.[/QUOTE]
myPtr1 = window.open('', winName+uniqueIdArray[url], tools);
if(myPtr1
&& myPtr1
&& myPtr1.name
&& myPtr1.name == winName+uniqueIdArray[url])
{
if(myPtr1.location.href=='about:blank')
{
myPtr1.location.href = url;
}
myPtr1.focus();
}
0.1.9 — BETA 5.18