Hi everyone,
I want to count the number of opened new windows.
But, when i close the opened newWindow ,then reduce the window count.
My new window have closelink also.
May be i choose either closelink or browser close window.
Update
If i have open 2 new window, then i calculate currently opened window.
But, if any window i close using ( close link, or browser closewindow), now only one new window is opened.
Here i don't know, how to show the opened window count is 1.
Totally 4 files are : MainPage.jsp , newwindow1.jsp , newwindow2.jsp and windowcount.js
MainPage.jsp
<f:view>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<a4j:loadScript src = "windowcount.js" />
</head>
<body>
<h:outputLink value="#" onclick="window.open('newwindow1.jsp','firstwindow','width=600,height=600');addWindowCount();">
<h:outputText value="new Window1"/>
</h:outputLink>
<h:outputLink value="#" onclick="window.open('newwindow2.jsp','secondWindow','width=600,height=600');addWindowCount();">
<h:outputText value="New window 2"/>
</h:outputLink>
<a4j:commandButton value="Get Window Count" onclick="getNewWindowCount();"/>
</body>
</html>
newwindow1.jsp
<f:view>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>First Window</title>
</head>
<body>
<a4j:commandLink id="firstWindowCloseLinkId"
value="Close Window"
onclick="javascript:window.close()"/>
</body>
</html>
newwindow2.jsp
<f:view>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Second Window</title>
</head>
<body>
<a4j:commandLink id="secondWindowCloseLinkId"
value="Close Window"
onclick="javascript:window.close()"/>
</body>
</html>
windowcount.js
var countNewWindow = 0;
function addWindowCount()
{
countNewWindow++;
}
function getNewWindowCount()
{
alert("Current opened NewWindow : " + countNewWindow);
}
Help me about this. Thanks for your effort.