Welcome to WebmasterWorld Guest from 54.158.183.188

Forum Moderators: open

Message Too Old, No Replies

How to Keep Firefox from caching iframe

     
5:14 pm on Sep 23, 2011 (gmt 0)

Junior Member

5+ Year Member

joined:Dec 31, 2007
posts: 198
votes: 0


I'm trying to get an iframe to resize, based on the contents. In IE, the iframe resizes when it first loads, then resizes when a different-sized page is clicked inside the iframe. But in FF, it resizes the first time, but then doesn't change when a new page is loaded. It caches the first page, then keeps that as the permanent height. I tried math.random - pragma no-cache, they didnt work. I tried to reload the parent, and it just goes into a loop - any help is appreciated!

main frame:
<html>
<head>
</head>
<body>
<iframe id='library' src='frame1.htm' frameborder='1' height="300"></iframe>
</body>
</html>


framed page1:
<html>
<head>
</head>
<body onload="resizeIframe()">
<script type="text/javascript">
function resizeIframe() {
var howtall = document.body.scrollHeight;
parent.document.getElementById('library').style.height=howtall;
}
</script>
<p>content frame1.htm - it's longer</p><p>content</p><p>content</p><p>content</p>
<p> <a href="frame2.htm">go to frame2</a> <p>content</p><p>content</p><p>content</p><p>content</p><p>content</p><p>content</p><p>content</p><p>content</p><p>content</p><p>content</p><p>content</p><p>content</p><p>content</p><p>content</p><p>content</p><p>content</p><p>content</p><p>content</p><p>content</p>
</body>
</html>


framed page 2:
<html>
<head>
</head>
<body onload="resizeIframe()">
<script type="text/javascript">
function resizeIframe() {
var howtall = document.body.scrollHeight;
parent.document.getElementById('library').style.height=howtall;
}
</script>
<p>content frame2.htm - it's shorter</p><p>content</p><p>content</p><p>content</p>
<p> <a href="frame1.htm">go to frame1</a> <p>content</p><p>content</p><p>content</p><p>content</p><p>content</p><p>content</p><p>content</p><p>content</p><p>content</p>
</body>
</html>
5:44 pm on Sept 24, 2011 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member jab_creations is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Aug 26, 2004
posts:3168
votes: 22


Use the following headers (presumming you have PHP)...

<?php
header('Cache-Control: max-age=0, public');
header('Last-Modified: Last-Modified: Mon, 29 Jun 1998 02:28:12 GMT');
?>


By setting the date in the past and having 0 seconds for cache control you effectively force the browser to fetch a fresh copy of the page. I'm not sure how well meta elements work if you don't have access to server side scripting however.

- John
12:51 am on Sept 27, 2011 (gmt 0)

Junior Member

5+ Year Member

joined:Dec 31, 2007
posts: 198
votes: 0


Thanks -
I don't have php. I did try various meta tags with dates, no-cache etc, but it still caches the original iframe page.
But thanks for the reply.
 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members