Je veux compter le nombre de nouvelles fenêtres ouvertes. Mais, quand je ferme la newWindow ouverte, alors réduire le nombre de fenêtres.comment compter les newwindows ouvertes?
Ma nouvelle fenêtre a closelink également.
Peut être que je choisis soit closelink ou navigateur fermer la fenêtre.
Mise à jour
Si j'ai ouvert une nouvelle fenêtre 2, puis-je calculer la fenêtre actuellement ouvert. Mais, si une fenêtre est fermée à l'aide de (lien proche, ou fenêtre de fermeture du navigateur), maintenant une seule nouvelle fenêtre est ouverte.
Ici, je ne sais pas, comment montrer le nombre de fenêtre ouverte est 1.
Totalement 4 fichiers sont: MainPage.jsp, newwindow1.jsp, newwindow2.jsp et 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);
}
Aidez-moi à ce sujet. Merci pour votre effort.
sont ces nouveaux fenêtres étant ouvertes par votre code à l'aide window.open()? –
oui. a ouvert une nouvelle fenêtre en utilisant la méthode window.open(). – Eswar