Thursday, May 23, 2024
 Popular · Latest · Hot · Upcoming
128
rated 0 times [  135] [ 7]  / answers: 1 / hits: 19749  / 8 Years ago, wed, may 18, 2016, 12:00:00

I have the following code (listed below). In short, when a user clicks the button All On it will open a popup window with yahoo.com. I want the window to remain open for 3 seconds, then automatically close with no additional interaction from the user.



Although the popup opens exactly as desired, I get this error when the close attempts to execute.



script438: Object doesn't support property or method 'close'
lights.html (11,31)



I am not a coder and cannot figure this out. Ultimately, this will primarily run on Safari iOS. And, obviously, the yahoo link will be replaced with a specific IP address. Thank you.



<!DOCTYPE HTML>
<html>
<head>
<title>Light Control Example</title>
<script type=text/javascript>
function allOn(){
var win = 'http://www.yahoo.com';

open(win,'1366002941508','width=1,height=1,left=5,top=3');

setTimeout(function() { win.close();}, 3000);
}
</script>
</head>
<body>
<h1>Lights Example</h1>

<input type=submit value=ALL ON onclick=allOn(); />

</body>
</html>

More From » popupwindow

 Answers
12

Give this a try



<script type=text/javascript>
function allOn(){
var win = window.open('http://www.yahoo.com','windowname','width=1,height=1,left=5,top=3');
setTimeout(function() { win.close();}, 3000);
}
</script>

[#62117] Monday, May 16, 2016, 8 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
annaw

Total Points: 18
Total Questions: 91
Total Answers: 98

Location: Guam
Member since Fri, Jun 18, 2021
3 Years ago
;