Quantcast
Channel: The Creative Juices Bo. Co. (CJBoCo) RSS 2.0 Feed
Viewing all articles
Browse latest Browse all 130

Prevent Apple's Safari Browser from Caching an iFrames Source or URL (Blog Entry)

$
0
0

Safari Caching Problem

Boy, I don't know how long this one has been a thorn in my side, but if you have ever tried dynamically creating or changing the content of an iFrame and you use Apple's Safari browser, then I'm sure you have run into this issue. For what ever reason, Safari caches the source (url) of an iFrame and whenever you try to change it's content, it wants to use the old data.

Well, not anymore. I came across a great little trick tonight and I though I would share. All you have to do is change the ID of the iFrame and Safari will update it with no problems. So if you're creating iFrames on the fly, just use this little JavaScript snippet:

iFrame.id = "IF_" + new Date().getTime(); // prevent Safari from using old data.

This can easily be modified for other languages. And if needed, you can update the SRC and then change the ID back to another name. (Useful if your using a custom CSS style for the element).

Hope this saves you a headache!


Viewing all articles
Browse latest Browse all 130

Trending Articles