I want to iframe/regularframe to an external site, but the external site is dynamic and changes alot. So how do i make an iframe or frame not cache so everytime the frame reloads itll be updated?
I want to iframe/regularframe to an external site, but the external site is dynamic and changes alot. So how do i make an iframe or frame not cache so everytime the frame reloads itll be updated?
Since the site inside the iframe is external, unfortunately you can't do anything to affect its cache settings. If the site was on your own server, you could, for example, use meta tags to specify the page's caching.
Actually, that's not quite accurate.
If you do something like, for example:... that should break caching in all Javascript-enabled browsers.Code:<iframe src="http://www.example.com/thepage.html" name="aframe"></iframe> <script type="text/javascript"> document.frames['aframe'].location.href += (document.frames['aframe'].location.href.indexOf("?") != -1 ? "?" : "&") + (new Date()).getTime(); </script>
However, it should be noted that this is a last resort only; if the external site's page changes regularly, they should have already taken server-side steps to assure that the cache is updated regularly.
Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!
ehhhh...it didn't work. Check it out here: http://muson.susanasjewelry.com/forum/randomhelp.html .Originally Posted by Twey
Ah yes Twey, I forgot about the "random number suffix" technique. How about this sartajc:
Code:<script type="text/javascript"> var randomnumber=Math.floor(Math.random()*100000) document.write(' <iframe src="http://www.freedonation.com/hunger/hunger_thankyou.php3?random='+randomnumber+'" name="aframe" width="100%" height="400"></iframe>') </script>
... but that's JS-dependent. Also doesn't cater for GET variables (which are likely, since it is, to quote, a "dynamic" page).
Use my code. I made three obvious mistakes, and probably about twenty subtle ones.
Code:<iframe src="http://www.freedonation.com/hunger/hunger_thankyou.php3" style="width:100%;height:400px;" name="aframe"></iframe> <script type="text/javascript"> var location = "http://www.freedonation.com/hunger/hunger_thankyou.php3"; (document.frames || window.frames)['aframe'].location.href = location + (location.href.indexOf("?") == -1 ? "?" : "&") + (new Date()).getTime(); </script>
Last edited by Twey; 05-28-2006 at 08:08 PM.
Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!
Well I thought I'd just throw the OP the line to get the fish.You're right, your code is more flexible though.
It worked....only in firefox. Not IE7. and most of the people that visit my site uses IE (grrrrr. i wish they used firefox. its so much better).
check it out here: http://muson.susanasjewelry.com/forum/help.htm .
Look what it does in firefox, and what it does in IE. actually does something in firefox, but does nothing in IE.
i used both ddadmins and tweys code. why won't it work in IE? (of course nothing works in IE)
oh yeah, i dont have to use iframe. regular frame, php, or anything else will work. as long as it works.
btw, theres millions of tech forums, but this one is the best one i have encountered.
For me it works in IE (v6). Firefox... what on earth?!
Ah... try this one:Code:<iframe src="http://www.freedonation.com/hunger/hunger_thankyou.php3" style="width:100%;height:400px;" name="aframe"></iframe> <script type="text/javascript"> var dokoka = "http://www.freedonation.com/hunger/hunger_thankyou.php3"; (document.frames || window.frames)['aframe'].location.href = dokoka + (dokoka.href.indexOf("?") == -1 ? "?" : "&") + (new Date()).getTime(); </script>
Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!
Originally Posted by Twey
Thank You! it worked in IE7! but now its not working in firefox...HOWEVER. thats not a problem. Ill just run both scripts! Thanx a lot! ill link back to this site!
check out the double iframe thingy here: http://muson.susanasjewelry.com/forum/rand.htm
Last edited by sartajc; 05-29-2006 at 11:29 PM.
Bookmarks