Question

I have an iframe in my index.html. Content is loaded into it through a menu bar:

...
<iframe name="iframe-main" id="iframe-main" src="content.html" frameborder="0">
</iframe>
...
/* menu bar */
<a href="impressum.html" target="iframe-main" name="impressum">Impressum</a>
...

The target url to be loaded into the iframe has a somewhat reduced header:

<html>
<head>
<link rel="stylesheet" type="text/css" href="css/default.css" media="screen"/>
</head>

<body style="margin: 0; border: 0; padding: 0;">
....

The iframe's url or some identifier does not show up in the url bar. i have tried adding name tags to the link loading the iframe but the url bar always shows the base url. is it possible to solve this (preferably html only, but i'm open to beginner-friendly js and php)?

Edit: I just noticed the iframe's history is stored in my browser history, so i can go back and forth and the iframes are loaded into the main window, but i cannot access it through the url bar (type a direct address) nor bookmark it. That would be the feature I want.
maybe some php snippet?

Was it helpful?

Solution

After some research I realised that iframes are not suitable for what I want, and I have to look at the problem from the other end. I ended up using php includes. This basically injects the always-the-same menu bar into the pages with varying content, before serving them out. I guess I thought the iframe solution would be more bandwidth-friendly but I can't tell the difference.
This tutorial got me on the right track and
This one explains how to do it, both with Server Side Includes and with PHP. It says SSI is easier and simpler than PHP but I really don't see why, at least not in this situation.
Since my project hasn't grown too much yet, the changes were very quick to implement.
I tested this on 2 servers and both SSI and PHP were available on both.
As a bonus, I got rid of those frame-resizing java scripts!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top