This functions show a /ticket.html popup window.
I need to check before if the window is already opened. If it is, cancel the new openning.
How could this be done?
function popitup() {
newwindow=window.open("ticket.html","_blank","toolbar=yes,scrollbars=yes, resizable=yes, top=500, left=500, width=730, height=700");
newwindow.moveTo(350,150);
if (window.focus)
{
newwindow.focus()
}
}
Regards,
You may save a reference to the window, when opening it. The
window.open
method returns awindowObjectReference
.With this reference, you can check if the window is closed (
closed
property, a boolean) or simply if the window is null (window
property, which will be aWindow
object or null, if closed).Simple example:
Reference: https://developer.mozilla.org/en-US/docs/Web/API/Window