PDA

View Full Version : Need Help with "setTimeout()" command


caclark
05-23-2003, 03:12 PM
In the below code I am trying to add a short delay in the middle of the script execution, but I can't get the "setTimeout()" to work.
The line seems to always be ignored.

Any help/new ideas would be appreciated!

-----------------------------------------------------------------------------------
----------------------- Example Of Code Used ------------------------------

<head>
<title>Edit</title>

<SCRIPT LANGUAGE="JavaScript">
<!-- // Hide from Old Browsers

function exit_win(){
exit_win=window.open('-link to page added here-','lockwin','width=50','height=50');
setTimeout("exit_win.window.close()",5000);
// exit_win.window.close();
}

// -->
</script>
</head>

A1ien51
05-23-2003, 04:57 PM
just try exit_win.close();

Mr J
05-23-2003, 05:11 PM
The timeout should work but I would like to point out that you do not use the single quotes between the window attributes only a comma and the smallest you can have a window is 100 x 100


exit_win=window.open('-link to page added here-','lockwin','width=50','height=50');


Other than that I tried your script and it worked ok.

<SCRIPT LANGUAGE="JavaScript">
<!-- // Hide from Old Browsers

function exit_win(){
exit_win=window.open('popup.htm','lockwin','width=100,height=100');
setTimeout("exit_win.close()",5000);
}

// -->
</script>

cheesebagpipe
05-23-2003, 05:33 PM
Here's something:

function exit_win(){

...creates global variable exit_win

exit_win=window.open('popup.htm','lockwin'..

...overwrites global variable exit_win

Might or might not be related to your problem, but it's not good.

caclark
05-23-2003, 05:56 PM
Thanks for your help.

The nearest I can tell is that it was choking on the window width & height being less than 100, beacuse once I changed that it fine.