iPad Safari IOS 5 window.close () cerrando la ventana incorrecta
Tenemos una aplicación para iPad que funciona en nuestros iPads más antiguos.
Abrimos enlaces externos usando var x = window.open (url)
al final del día, cuando el usuario cierra esta parte de la aplicación, revisamos todas las ventanas que abrió y hacemos x.close () para cada una y todo está bien.
Probar en el nuevo iPad con iOS 5 y las pestañas encantadoras, abrir las nuevas ventanas (aunque ahora se abren como pestañas) está bien, pero hacer x.close () no parece cerrar necesariamente x, puede cerrar la ventana y o z. Hacer x.focus () o y.focus () funciona bien, la pestaña correcta se enfoca, pero cerrar parece elegir la pestaña que quiera.
¿Es esto un error o estoy haciendo algo mal? Programa de ejemplo:
<html>
<head></head>
<body>
<script>
//The openWindow array will hold the handles of all open child windows
var openWindow = new Array();
var win1;
var win2;
//Track open adds the new child window handle to the array.
function trackOpen(winName) {
openWindow[openWindow.length]=winName;
}
//loop over all known child windows and try to close them. No error is
//thrown if a child window(s) was already closed.
function closeWindows() {
var openCount = openWindow.length;
for(r=openCount-1;r>=0;r--) {
openWindow[r].close();
}
}
//Open a new child window and add it to the tracker.
function open1() {
win1 = window.open("http://www.yahoo.com");
trackOpen(win1);
}
//Open a different child window and add it to the tracker.
function open2() {
win2 = window.open("http://www.google.com");
trackOpen(win2);
}
//Open whatever the user enters and add it to the tracker
function open3() {
var newURL = document.getElementById("url").value;
var win3= window.open(newURL);
trackOpen(win3);
}
</script>
<input type="button" value="Open 1" onclick="open1()">
<input type="button" value="Open 2" onclick="open2()">
<input type="button" value="Focus 1" onclick="win1.focus()">
<input type="button" value="Focus 2" onclick="win2.focus()">
<input type="button" value="Close 1" onclick="win1.close()">
<input type="button" value="Close 2" onclick="win2.close()">
URL: <input type="text" id="url"> <input type="button" value="Open URL" onclick="open3()">
<input type="button" value="Close All" onclick="closeWindows()">
</body>
</html>