homepage Welcome to WebmasterWorld Guest from 54.242.200.172
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe to WebmasterWorld

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

    
How to Keep Firefox from caching iframe
vero




msg:4366416
 5:14 pm on Sep 23, 2011 (gmt 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>

 

JAB Creations




msg:4366780
 5:44 pm on Sep 24, 2011 (gmt 0)

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

vero




msg:4367556
 12:51 am on Sep 27, 2011 (gmt 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.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved