I want to open up a link (of another site) on new page in iframe. For example when the link on page A is clicked, it opens a new window(Page b) of same website and make the link of another site to open in iframe..

Please help....

could you try using taget="_BLANK" in your link?

But i want to know the way to pass URL from one page to another. Please help

Member Avatar for diafol

Do you want to embed another page inside another? Would using a template be better (e.g. top and footer) for a consistent look? iframes should be avoided where possible. They don't size well as they are not aware of the height/width of their contents.

There are loads of ways of doing this - you could use an include file for example.

If you are determined to do this:

<?php
$default = "mypage.php";
if(isset($_GET['page'])){
  $url = $_GET['page']; 
}else{
  $url = $default;
}
?>

<iframe src="http://www.mysite.com/<?php echo $url;?>"></iframe>

Say the iframe is in index.php and you want to show profile.php in the iframe:

index.php?page=profile.php

It's really untidy, but you get the idea. Alternatively, you could pass a page id for the page parameter for which your script then searches the DB. Again, this could be done with javascript, which changes the src value when you click a link.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.