Click to See Complete Forum and Search --> : Setting window.open to the current window


Wildcat
09-29-2003, 02:16 PM
I'm trying to write a simple framebreaker script for the splash page of my site, and I'm wondering how I can get it to open in the current window for the user. My script does open the page without frames, but in another window.



<script language="JavaScript"><!--

function breakOut() {
if (window.parent != window.document) {
thisPage = window.open('index.html')
}
else { }
}

--></script>

</head>
<body onLoad="breakOut()">



I will appreciate your help, and if anyone can tell me how to do this without using an if statement, because it seems rather clumsy.

pyro
09-29-2003, 02:24 PM
I would do it more like this:

<script type="text/javascript">
if (top.location.href != self.location.href) {
top.location.href = self.location.href;
}
</script>

gil davis
09-29-2003, 02:25 PM
The window.open() method as you have used it will always open a new window.

Most frame breakout pages modify the window.top.location property.

Wildcat
09-29-2003, 02:51 PM
Thanks; that's exactly what I'm looking for!