重新执行JavaScript文件 [英] Re-executing JavaScript files

查看:53
本文介绍了重新执行JavaScript文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

之前我问过这类问题(应用程序无法动态_re_load JavaScript文件)但我无法解决问题(如果它有任何解决方案),所以我将以另一种方式,更简单的方式:

I asked this sort of question before ( Application fails to dynamically _re_load JavaScript files ) but I couldn't quite resolve the problem (if it has any solution), so I will put this in another fashion, a simpler one:

可以从浏览器的内存中卸载文件以便后重新加载吗?

(显然删除标签是不够的。)

Can one unload a file from the browser's memory for posterior reloading?
(Removing the tag is not enough apparently.)

或更相关,如果在删除标签后重新插入标签,该代码是否重新运行(显然不是)?

Or more relevant, if a reinsert the tag after removing it, is that code rerun (apparently not)?

如何完成后者?

提前致谢。

推荐答案

您可以生成一个随机数,然后将其附加到文件名末尾这个: ... / script.js?r = 0.25300762383267283 。然后浏览器会认为它是一个新文件,而不是从缓存中引用它。

You could generate a random number and then attach it to the end of the filename like this: .../script.js?r=0.25300762383267283. Then the browser would think it's a new file and not reference it from the cache.

这篇关于重新执行JavaScript文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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