Doug,
> Now the problem is that some websites have "frame breakout" scripts.
> When the iframe loads these pages they automatically takes over the
> entire session
You are quite right, the cross domain resrictions would make this pretty
much impossible to avoid. You cannot load their page into an iframe if they
refuse to allow it.
In theory, you can use an object instead, but IE would almost certainly fail
at this.
> PS. I also thought of redefining the "top" object or overriding its
> properties or methods.
'top' is a property unique to each frame, so you cannot override the child's
'top' from the parent frame. However, since 'top' and 'top.location' are
objects, you may be able to delete them (not sure how successful this might
be):
delete location; //this way, they can't change it.
The most reliable way to do what you need is a url proxy, but this would eat
your bandwidth, and you would need to change the base href of the page to
reflect its original location (so that all the links and images work);
Code:
<iframe src="getPage.php?url=http://example.com/"></iframe>
then in getPage.php:
<?
if( preg_match("/^http:\/\//",$_GET['url']) ) {
if( $file = fopen($_GET['url'],'rb') ) {
$contents = '';
$base = '<base href="'.urlencode($_GET['url']).'">';
while( !feof( $file ) ) { $contents .= fread( $file, 8192 ); }
if( stristr( $contents, '</html>' ) ) {
$contents = preg_replace("/<\/html>/i",$base.'</html>',$contents);
} else {
$contents = $base.$contents;
}
//this regexp may have an ugly effect on some pages - you will need to
//tailor the regexp to suit your needs.
$contents = preg_replace("/(=|\s|\()top\b/i","$1".'window',$contents);
print $contents;
}
}
?>
Hope this helps
Mark 'Tarquin' Wilton-Jones - author of
http://www.howtocreate.co.uk/