[英]JavaScript - Cache bookmarklet but always load the latest version
I'm working on a JavaScript bookmarklet that lets users send a link to a website. 我正在开发一个JavaScript 书签 ,让用户可以发送链接到网站。 Is it possible to cache the bookmarklet but also reload it if a new version is available?
是否可以缓存书签,但如果有新版本可以重新加载它? (Maybe with htaccess?)
(也许用htaccess?)
Edit: This is my bookmarklet: 编辑:这是我的书签:
javascript:javascript:(function(){new_script=document.createElement('SCRIPT');new_script.src='https://www.example.com/folder/bookmarklet.js?v=1';document.getElementsByTagName('head')[0].appendChild(new_script);new_script.type='text/javascript';})();
The nature of bookmarklets is that "cache" is irrelevant to them: The exist entirely within the browser's bookmark storage, there is no server call (unless you write one as part of the bookmarklet code). bookmarklet的本质是“缓存”与它们无关:完全存在于浏览器的书签存储中,没有服务器调用(除非你将一个编写为bookmarklet代码的一部分)。
You could have your bookmarklet load and check a version string from your website using ajax or JSONP. 您可以加载书签并使用ajax或JSONP从您的网站检查版本字符串。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.