how to count opened newwindows?
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="开发者_StackOverflow社区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.
You can't.
JavaScript doesn't have access to other open windows, unless they were opened using window.open()
.
Just i add one more button and javscript. But i can't get the openedPopup window count. MainPage.jsp
<a4j:commandButton value="PopupCount" onclick="countOpenPopups();"/>
And javaScript is :
function countOpenPopups()
{
var iCount = 0;
for (var i = 0; i < eWebEditPro.popups.length; i++)
{
if (eWebEditPro.popups[i].isOpen())
{
iCount++;
}
}
alert("iCount : " +iCount);
}
I refer this. http://dev.ektron.com/kb_article.aspx?id=568
I think this script related to eWebEditPro. Is possible to implement to normal browser link(FireFox,IE etc...)
精彩评论