Hunter
Hunter

Reputation: 458

Opening a link inside a website

My dad used to make websites and while looking through one, I noticed that while staying on the same address, he was able to display an external website, within that same page. He basically just had a sidebar and the rest was there to open the links in from the bar. I am trying to achieve a similar effect.

PS: I don't think he had to use any PHP, he did it back in like, 1998.

Upvotes: 1

Views: 163

Answers (3)

SaidbakR
SaidbakR

Reputation: 13544

The guide line of doing this nowadays:

1- Make an iframe in your page with the name attribute such as <iframe name="myLinksWin"></iframe>

2- In every link that you want it to be opened in this iframe you have to use the target attribute with value equals to the iframe name attribute <a href="http://yahoo.com" target="myLinksWin">The link</a>

However, I think in 1998 your dad, used frameset.

Upvotes: 1

Maxime Lorant
Maxime Lorant

Reputation: 36181

Technically, you can include a page into another one with <iframe> It'll produce a box inside your page and load the page requested in parallel. A simple example can be found here.
To make your own page, you just have to change the iframe line:

<html>
<body>
<h1>Your fancy web page</h1>

    <iframe src="http://cat-bounce.com/">
      <p>Your browser does not support iframes.</p>
    </iframe>

</body>
</html>

... will load a page with a title a page with some cat to bounce in a box. You can interact with both pages, but they can't shared object between them.
Also, some websites doesn't support iframes and will returns blank box, like StackOverflow, Google, etc.

Be aware this method is quite unpopular today.

Upvotes: 1

hkk
hkk

Reputation: 2149

Method 1
Use an iframe, which allows you to display content from other sources. However, not all websites will support this. Sites can easily detect if they are in an iframe by comparing window.location with document.location.

Method 2
Use AJAX to load parts of other pages (I'm not sure if this would work on all pages, though). It may cause problems if you need to load images/stylesheets/scripts on that page with a source defined relatively.

Method 3 Load pages from PHP using cURL. This will load any page, but it may cause problems if you need to load images/stylesheets/scripts on that page with a source defined relatively.

Upvotes: 0

Related Questions