我想阻止我的 iframe 被缓存。第一页没有问题。然后我像这样使用 PHP:
<iframe id="my_iframe" src="index.html#<?php echo time() ?>"></iframe>
我遇到的问题是防止在 iframe 内单击链接时发生chaching。例如:
<a href="newpage.html">this page will be cached</a>
如何防止缓存“newpage.html”?我可以使用 java 脚本以某种方式向 src 添加时间戳吗?
最佳答案
是的,你可以做到,
var linksList = document.getElementsByTagName('a');
for( var i=0,len=linksList.length;i<len;i++ )
linksList [i].href += '#'+new Date();
这个脚本应该放在 body 标签结束之前,或者通常应该在 DOM 加载之后调用。
现在,是否有一种后端方法(带有 header )来要求浏览器不要缓存某些特定页面?
关于javascript - 使用javascript将时间戳添加到iframe中的src(防止缓存),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6409929/