M
Madame Blablavatsky
hello,
i have a few links on a page. when one clicks a link an pop up window with
an image opens.
when people click an other link i want the already availible pop up window
to close before
the other pop up window opens.
i just can't get it right, i always get an error message:
line: 23
char: 20
error: object doesn't support this property or method
the line with the error is:
vensters[x].close();
here is the source:
======================== source ====================
<html>
<head>
<script style="text/javascript">
// 'teller=1': no pop up window open;
// 'teller=0': pop up window open;
var teller;
teller = 0;
// array with pop up windows;
var vensters = new Array(3);
vensters[0] = "win1";
vensters[1] = "win2";
vensters[2] = "win3";
function openWindowPlaatje(num) {
var x;
// if an pop up is already open, close it before opening a new pop
up;
if(teller == 1){
for(x = 0; x < vensters.length; x++){
if(vensters[x] != num ){
vensters[x].close(); // this line gives error message;
}
}
}
// open the selected pop up;
if(num=="win1"){
win1=window.open("plaatje1.html","",'top=250,left=250,
width=238,height=255');
teller = 1;
}
if(num=="win2"){
win2=window.open("plaatje2.html","","top=250,left=250,width=50,height=50");
teller = 1;
}
if(num=="win3"){
win3=window.open("plaatje3.html","","top=250,left=250,width=150,height=150")
;
teller = 1;
}
}
</script>
</head>
<body>
<a href="JavaScript: openWindowPlaatje('win1')" >plaatje 1</a><br>
<a href="JavaScript: openWindowPlaatje('win2')" >plaatje 2</a><br>
<a href="JavaScript: openWindowPlaatje('win3')" >plaatje 3</a><br>
</body>
</html>
=====================================================
i have a few links on a page. when one clicks a link an pop up window with
an image opens.
when people click an other link i want the already availible pop up window
to close before
the other pop up window opens.
i just can't get it right, i always get an error message:
line: 23
char: 20
error: object doesn't support this property or method
the line with the error is:
vensters[x].close();
here is the source:
======================== source ====================
<html>
<head>
<script style="text/javascript">
// 'teller=1': no pop up window open;
// 'teller=0': pop up window open;
var teller;
teller = 0;
// array with pop up windows;
var vensters = new Array(3);
vensters[0] = "win1";
vensters[1] = "win2";
vensters[2] = "win3";
function openWindowPlaatje(num) {
var x;
// if an pop up is already open, close it before opening a new pop
up;
if(teller == 1){
for(x = 0; x < vensters.length; x++){
if(vensters[x] != num ){
vensters[x].close(); // this line gives error message;
}
}
}
// open the selected pop up;
if(num=="win1"){
win1=window.open("plaatje1.html","",'top=250,left=250,
width=238,height=255');
teller = 1;
}
if(num=="win2"){
win2=window.open("plaatje2.html","","top=250,left=250,width=50,height=50");
teller = 1;
}
if(num=="win3"){
win3=window.open("plaatje3.html","","top=250,left=250,width=150,height=150")
;
teller = 1;
}
}
</script>
</head>
<body>
<a href="JavaScript: openWindowPlaatje('win1')" >plaatje 1</a><br>
<a href="JavaScript: openWindowPlaatje('win2')" >plaatje 2</a><br>
<a href="JavaScript: openWindowPlaatje('win3')" >plaatje 3</a><br>
</body>
</html>
=====================================================