如何强制IE重新加载JavaScript? [英] How to force IE to reload javascript?

查看:139
本文介绍了如何强制IE重新加载JavaScript?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Vista上使用IE 8,每次更改javascript文件然后开始调试时,我必须按Ctrl + F5重新加载我的javascript。有什么方法可以让我在开始调试时自动重新加载javascript,但在浏览网页时不会失去性能提升吗?

I'm using IE 8 on Vista, and everytime I change a javascript file and then start debugging, I have to hit Ctrl+F5 to have it reload my javascript. Is there any way to make it automatically reload javascript when I start debugging, but not lose the performance gains when just browsing the net?

是的,我知道你可能不会喜欢IE,但请记住问题不是什么是最好的浏览器?。

Yeah yeah I know you probably don't like IE, but keep in mind the question isn't "What's the best browser?".

推荐答案

添加一个字符串at用于中断缓存的URL的结尾。我通常(使用PHP):

Add a string at the end of your URL to break the cache. I usually do (with PHP):

<script src="/my/js/file.js?<?=time()?>"></script>

因此,每当我正在处理它时它会重新加载,然后在它工作时将其取下投入生产。实际上我把它抽象出来了一点但是这个想法保持不变。

So that it reloads every time while I'm working on it, and then take it off when it goes into production. In reality I abstract this out a little more but the idea remains the same.

如果你看看这个网站的来源,他们会在最后添加修订号。 URL以类似的方式强制在更新javascript文件时对我们进行更改。

If you check out the source of this website, they append the revision number at the end of the URL in a similar fashion to force the changes upon us whenever they update the javascript files.

这篇关于如何强制IE重新加载JavaScript?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆