IE8后退按钮和动态内容 [英] IE8 back button and dynamic content
问题描述
我有一个页面,它会提取一个外部JavaScript文件,然后在该页面中动态生成一些内容(基本上会插入一些DIV和一个Flash对象)。
I have a page that pulls an external JavaScript file, which then generates some content dynamically into that page (basically inserts some DIVs and a Flash object).
用户导航离开此页面,然后按后退按钮,Safari和Firefox显示生成的内容,但IE 8没有。
When ever the user navigates away from this page and then pushes the 'back' button, Safari and Firefox display the generated content, but IE 8 does not.
什么是最好的IE的做法是保留历史中的动态内容?或者我是否必须侦听某些特定事件然后重新启动我的JavaScript?
What is the best practice for IE to retain dynamic content in history? Or do I have to listen for some specific event and then restart my JavaScript?
顺便说一句,我有jQuery,所以也欢迎相关的插件建议。
BTW, I have jQuery in place, so relevant plugin suggestions are also welcome.
编辑:这里是演示链接:
http://mmstest.eenet.ee/embed/281
EDIT: here is link to demo: http://mmstest.eenet.ee/embed/281
如果您点击底部的Google链接,然后转到返回,Safari和FF将再次向您显示视频,IE8不会。
If you click the Google link at the bottom and then go Back, Safari and FF will show you the video again, IE8 does not.
推荐答案
我使用IE Developer进行了快速测试工具栏 - 我点击回来,没有发生任何事情,如你所说。我再次尝试但在点击之前我清除了我的缓存,当我回去时,视频出现了。
I did a quick test using the IE Developer toolbar- I clicked back and nothing happened as you mentioned. I then tried again but before clicking back I cleared my cache, and when I went back the video showed up.
尝试确保强制IE清除浏览器缓存和你的即使点击背页也应该加载视频。
Try ensuring you force IE to clear the browser cache and your video should load even when clicking on the back page.
----加速对话后添加的编辑---
---- EDIT ADDED AFTER CACHING CONVERSATION ---
这不应该影响客户端浏览器从缓存中获得的Web应用程序的性能,因为只有触发JS嵌入视频的页面才会发送回标头以使缓存过期/禁用。 / em>其他所有内容 - JS脚本,图形/图像和视频事件 - 仍将由客户端缓存。
This should not affect the performance of your web application the client browser gains from caching, since you would send back headers to expire/disable the cache only for the page that fires off the JS to embed the video. Everything else- the JS scripts, the graphic/images, and event the video- would still be cached by the client.
----编辑:更新从评论中包含完整的解决方案---
---- UPDATED TO INCLUDE FULL SOLUTION FROM COMMENTS ---
要禁用缓存包含的JavaScript文件,一种解决方案是将查询参数中的随机数附加到URL,以便浏览器将不缓存结果。
To disable caching of included JavaScript files one solution is to just append random number in query parameter to the URL, so that browser will not cache the result.
<script src="jquery.js?t=<?PHP echo rand() ?>">
这可以避免修改网络服务器设置以禁止在系统范围内缓存静态JavaScript文件。
This avoids the need to modify webserver settings to disable caching static JavaScript files system-wide.
这篇关于IE8后退按钮和动态内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!