I've laid out a site using an iframe for the main content so the header and footer wouldn't reload with each page turn. However when navigating back to the site using History, only the center content from the iframe loads [w/out header footer]. Is there a way to code these pages so that they load inside the index document if called explicitly? Or is the only answer to redesign the page without iframes somehow? I can link to the test page if necessary.

Recommended Answers

All 2 Replies

In your pages that should be in your iframe

<script type='text/javascript'>
<!--
if(self.location==top.location) top.location.replace('http://mysite.com?frame=' + self.location) ;
-->
</script>

I dunno what the form for html shtml pages is, never thought about it before but in php

<iframe src="<?php if(!$frame) {echo 'main.html';} else {echo $frame; } ?>" frameborder='0' width='100%' height='900'></iframe>

Revata,

I'd recommend route 'B'. Redisign your pages to serve them complete with header and footer each time.

Many many sites do this and the overhead is generally minimal because (a) any graphical content (jpegs/gifs/pngs) is cached by all modern browsers and (b) the text component (which will be reserved) is generally small in comparison to images and the rest of the page. Oh yes, put javascript functions and CSS in separate files so they too can be cached.

To save having to code your headers and footers on every page, you need something server-side to build the page dynamically. Any of [ssi | php | jsp | asp] will do the job. With a little imagination you can even build headers and footers client-side in Javascript. I have done that before.

Airshow

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.