Forum Moderators: open

Message Too Old, No Replies

Javascript Onload Problem

Timeout

         

Francis

4:25 pm on Oct 19, 2004 (gmt 0)

10+ Year Member



Is there something wrong with this:

<body onLoad="setTimeout(window.close, 1000)">

If there is none, then why isn't it working!

It use to work before, now I'm racking my brains out because I need this to work completely.

Any advice. Thanks

birdbrain

5:43 pm on Oct 19, 2004 (gmt 0)



Hi there Francis,

Is there something wrong with this:

Yes;)

It should be...

<body onload="setTimeout('window.close()',1000)">

...and then it will only work in window that
has been intentionally opened with javascript.

birdbrain

Francis

1:47 am on Oct 20, 2004 (gmt 0)

10+ Year Member



I tried using the one that you have mentioned, and it's still not working.

I'd also like to mention the following:

1. I'm using IE 6.0 on Windows XP
2. When used with the following browsers, the previous code worked:

a. Netscape
b. Mozilla Firefox

Any good explanation.

StupidScript

9:23 pm on Oct 20, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'd say the explanation is "IE6 on WinXP".

Check your IE6 Security and Privacy settings to ensure that the browser has permission to execute Javascript code that pertains to windows. If this is the PRIMARY or parent window, then you need special permission to close it without alerting the user. If it is a child window, opened by Javascript, then there is no such security issue.

Can we assume you are not receiving an alert?

Check your XP firewall settings for the same permissions. If you're running SP2, there's a bit more to do, probably involving resetting your firewall settings to the way they were before you installed SP2 (and defeating most of the security patches in SP2 at the same time!)

Birdbrain is right in that the function you want to execut needs to be enclosed. You might also assign the timeout to a variable, i.e.:

closeWin=setTimeout('self.close',10000)

I don't know all the implications, but I've seen some browsers repeating timeout instructions over and over again without the variable. You need the variable in order to clearTimeout(closeWin), so it's clear invoking the functions with or without the variable are treated differently at some level.

Note I suggest you use "self.close" instead of "window.close", because it's a little more specific.

Francis

5:43 am on Oct 21, 2004 (gmt 0)

10+ Year Member



I also think that the key was the winxp update installation that triggered the malfunction.

I will try all your suggestions. Thank you very much... again.