Forum Moderators: open

Message Too Old, No Replies

pop-up loads in new window or pop-up loads in old window

java script question/confusion

         

stcrim

9:27 pm on Apr 9, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Why does this code create a new window everytime its loaded and the code below it reloads the same window everytime its run?
__________________________________________________
<script language="JavaScript">
function stc() {
var stc = open('http://www.mysite.com/myfolder/index.html');
self.focus();
}
setTimeout("stc()",0000);
// -->
</script>
_________________________________________________

<script language="JavaScript">
<!-- Hide script from older browsers
{myWin = open('', 'winin','top=10,left=10,toolbar=0,menubar=0,scrollbars=1,status=0,resizable=1,width=650,height=460');
myWin.blur();
myWin.location = 'http://www.mysite.com/myfolder/index.html';}
// end hiding contents -->
</script>
____________________________________________________

I would like to use the top code and have it reload the window rather than clobber visitors with multiple pop-ups. With the top code the window forms behind the browser - with the bottom code the window forms in front and then drops behind.

Any thoughts?
-s-

korkus2000

9:33 pm on Apr 9, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



With this line

setTimeout("stc()",0000);

you are creating a no delay call for a new window.

You are also telling the opener window to take focus with this code.

self.focus();

This code pushes the popup behind the browser

myWin.blur();

So what do you want to reload?

ShawnR

11:14 pm on Apr 9, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The top code doesn't name the target frame or window, hence it opens in a new one (I suppose default is "_blank"; haven't looked it up).

The second code names the target frame/window ('winin'), so the first time it runs it will pop open a new window and call it 'winin', and subsequent times the function is called, the page will open in the 'winin' window.

You could add a second argument to Open() (the name of the frame/window, or '_self', or you could replace the contents of stc() with:

window.location.href = 'http://www.mysite.com/myfolder/index.html';

... And I agree with Korkus that you probably don't want to set a timeout of zero, etc

Shawn

stcrim

1:30 am on Apr 10, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thank you - this worked beautifully:

<script language="JavaScript">
function stc() {
var stc = window.open('http://www.mysite.com/myfolder/index.html','winin');
self.focus();
}
setTimeout("stc()",3000);
// -->
</script>

-s-