Verify Open Window

[Total: 0    Average: 0/5]

This will open up a new window and then when you click the button verify if it is open or not.

Body Code:

<a href="javascript:createWindow()">start example</a>
<script language="JavaScript">
<!--
var win1;
var scriptTags = "<html>" +
                 "<title>Sample Window</title>" + "a" +
                 "<script>var winOpen=true;</script>" +
                 "</html>";

function createWindow() {
  win1 = window.open("", 
                     "win1",
                     "height=60,width=175,scrollbars=no");
  win1.document.open();
  win1.document.writeln(scriptTags);
  win1.document.close();
}

function validateWindow() {
  if (win1.winOpen == null)
     alert("Window does NOT exist.");
  else {
     win1.focus(); // give window focus 
     alert("Window exists!");
  }
}
//-->
</script>
<form>
<input type=button 
       value='Check Window' 
       onClick="validateWindow()">
</form>

Times Viewed: 0

Leave a Reply

Your email address will not be published. Required fields are marked *