View Full Version : IFrame Help!

09-29-2008, 03:27 PM
Hi There people

Basiclly I have an index page which has a menu which loads pages dynamicly into an Iframe.

I want to be able to go to the url of the pages to be contained within the Iframe and have them display in the Iframe.

Ie, when google caches the pages contained in the Iframe I want them to still be within the Iframe.

To View my source code goto http://www.selectties.co.uk

obvously the site is still under construction.

Hope this makes sense to someone other than me.


09-29-2008, 06:33 PM
I'm not sure I understand... what is it that you are trying to do?

09-29-2008, 07:07 PM
I would strongly advise AGAINST using IFRAMES nowadays.

If you are wanting to load dynamic and/or external content into containers on your site... I would recommend using DIVs and AJAX to load the content into the DIVs

09-30-2008, 07:53 AM
I am trying to make sure that when some one clicks on a link to one of my pages on a search engine that the whole page displays and not just the content inside the Iframe.

Eg, I have an index page that has a header and footer and it loads the content pages into an Iframe.

I want to be able to click a link to a content page and still have it load in the Iframe.

Hope this makes more sense


09-30-2008, 09:41 AM
This sort of thing can be done, but not with HTML. If you have server side code available, it could be probably be used - I'm not sure how or 100% sure it can though - you could ask in the appropriate forum - say, if you have PHP ask there, asp ask there.

Using javascript you can tell whether or not your page is loaded into a frame at least (probably even the desired iframe page), if not - load the appropriate top page and tell that top page to load said page into its iframe. Or just use javascript to notify the user that they are on an 'orphan' page and to give them a link to your main page. The only trouble with either of those is, not all users have javascript enabled. Also, some may resent having that done automatically if all they really wanted was the page they originally got.

You really would be better off though devising some other way of organizing your site that didn't rely upon frames or iframes.

09-30-2008, 04:03 PM
Cheers ( moderators )

I am too into this project to change it now but I am looking into your suggestions and I will probably give them some serious consideration for my next project.

Anyway I did find a temporary fix by putting the following code in the orphan pages

<script type="text/javascript">
if (window == top) {
var url='window.location.replace("http://www.yoursite/index.html?var1='+window.location.href+'")';

this forces orphan pages to open the index page or page of your choice.

Cheers dynamic drive you guys are the iSHhhhhh