Click to See Complete Forum and Search --> : loading page in iframe - changing 'top'


shauny
05-06-2004, 03:35 PM
hi, i'm an absolute js noob, and was wondering if this can be done... i have a page which cannot be loaded in an iframe, as it contains this code:


<script language="JavaScript">
<!--
if (self != top)
{
alert('Page cannot be loaded inside frame...')
location.replace("http://www.google.com");
}
-->
</script>


so, i need self to equal top, or the page will be redirected. how can i do this?

Paul Jr
05-07-2004, 12:13 AM
Try comparing URLs instead:

if(parent.location != self.location) {
alert("This page cannot be loaded in a frameset.");
location.replace("http://www.google.com/");
}

shauny
05-07-2004, 02:29 AM
nono, i can't edit the html in that page... i need to get around the if statement some other way...

Kor
05-07-2004, 02:43 AM
nono, i can't edit the html in that page...

That means that page has not the same domain as your parent page. In this case you must know that is NOTHING you can do, as there is no way to acces in iframe a different domain sited page's elements (objects, functions). This is due to obvious security issues implemented in all browsers.