Does anyone know how to open a link in an iFrame in the parent window if the framed page is not in the same domain?
| SitePoint Sponsor |
Does anyone know how to open a link in an iFrame in the parent window if the framed page is not in the same domain?

I guess some sort of JavaScript.
Pretty sure it's NOT possible, strictly because it's more secure. You wouldn't want an external domain messing around with your page, this is usually limited by browsers.
What about something server-side?
What you're asking, I'm afraid is pretty much impossible. I've only seen frame interaction where the frame generated was from the domain that opened it. I'm not sure what you would be able to do server-side wise, because server-side code just outputs front end code and you still won't be able to access that parent window.
How would you make a server-side IFRAME?


Maybe something like this ?
HTML Code:<a href="?file=link1"> link 1</a> <a href="?file=link2"> link 2</a> <a href="?file=link3"> link 3</a>PHP Code:
<?php
$file = $_GET['file'];
if (empty($file)){
$file = "welcome.php";
} else{
$file = $file .".php";
$iframe = "<iframe src=\"". $file ."\" width=\"100%\" height=\"300px\"> ";
$iframe .= "<p>Your browser does not support iframes.</p> ";
$iframe .= "</iframe> ";
echo $iframe
?>


I'm positive he knows and is familiar with how server-side languages work ( he is knowledgeable ). I think he meant to say how could you use server-side to solve this problem instead of how to generate an iframe using a server-side language, which gives you the exact same result meaning we're at the same point and haven't progressed further![]()
Bookmarks