<html> <head> <title>Opening and Closing Windows</title> <script type=\"text/jav
ID: 3547674 • Letter: #
Question
<html>
<head>
<title>Opening and Closing Windows</title>
<script type="text/javascript">
var myWindows = new Array();
var windowNo = new Array("Window1", "Window2", "Window3");
var leftPos =[200, 450, 700];
function createWindows()
{
for (i=0; i < 3; i++)
{
var j= i*200;
myWindows[i] = window.open("http://www.google.com/", windowNo[i],
"height=200,width=200,left="+leftPos[i])
}
}//end of createWindows
</script>
</head>
<body>
<h1>Open and Close windows</h1>
<h2>Press buttons to open and close windows</h2>
<form>
<input type="button" id="createWindowsbtn" value="start to create windows"
onclick="createWindows();">
</form>
</body>
</html>
Explanation / Answer
<html>
<head>
<title>Opening and Closing Windows</title>
<script type="text/javascript">
var myWindows = new Array();
var windowNo = new Array("Window1", "Window2", "Window3");
var leftPos =[200, 450, 700];
function createWindows()
{
var ran=Math.floor((Math.random()*3));
window.open("http://www.google.com/", windowNo[0],
"height=200,width=200,left="+leftPos[ran]);
}
//end of createWindows
</script>
</head>
<body>
<h1>Open and Close windows</h1>
<h2>Press buttons to open and close windows</h2>
<form>
<input type="button" id="createWindowsbtn" value="start to create windows"
onclick="createWindows();">
</form>
</body>
</html>
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.