...

View Full Version : Javascript only working when Refreshed



blackw0lf
07-12-2004, 09:55 PM
I have a simple window.open script that won't work when the page is initially pulled up, but works when the page is refreshed. Is this an environment issue or is there some other script that may work for this?

<SCRIPT language="JavaScript">
window.open("http://www.cnn.com","Zippy","width=420,height=375,resizable=yes,scrollbars=yes");
</SCRIPT>

Roy Sinclair
07-12-2004, 10:16 PM
Perhaps there are other scripts on the page which are erroring out and causing that script to not be executed.

blackw0lf
07-12-2004, 10:44 PM
It seems if that was the case then it wouldn't work at all, but it does work when the page is refreshed.

Willy Duitt
07-12-2004, 11:01 PM
I agree with Vladdy's response to your question which was also posted here (http://www.webdeveloper.com/forum/showthread.php?threadid=39374)....
It doesn't work for me no matter what....
Must be the popup blocker....

blackw0lf
07-12-2004, 11:16 PM
I have also tried placing this in the <head>

<SCRIPT language="JavaScript">
function init() {
logpop=window.open("http://www.cnn.com","Zippy","width=420,height=375,resizable=yes,scrollbars=yes");
logpop.focus();
}
<SCRIPT>

and placing this in the <body> tag:

onload="init()"

When the page first loads I get an error stating that logpop is null or not an object. This error is being caused by logpop.focus(); because the window did not open. Then when I refresh the page, it works fine.

Garadon
07-13-2004, 09:50 AM
the 1st script works fine in my IE6+ browser and its quite annoying to.

lordofthesword8
07-13-2004, 11:14 AM
logpop=window.open("http://www.cnn.com","Zippy","width=420,height=375,resizable=yes,scrollbars=yes");


In this line, with the logpop=window.open, replace it with logpop = window.open.

If this fixs it it means that log pop was not being declared properly. As for the fact it only works when refreshed ive no clue...

glenngv
07-13-2004, 11:51 AM
In this line, with the logpop=window.open, replace it with logpop = window.open.

If this fixs it it means that log pop was not being declared properly. As for the fact it only works when refreshed ive no clue...
The space doesn't matter though it's more readable if you put one.

lordofthesword8
07-13-2004, 01:36 PM
Thanks for that I always thought it was part of the syntax.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum