[英]onclick refresh but not from cache?
I have this button to refresh the page 我有这个按钮来刷新页面
echo '<input type="button" value="Reload Page"
onClick="window.location.href = window.location.pathname;">';
What is the easiest way to make sure that the page is read not from cache? 确保不从缓存中读取页面的最简单方法是什么? To use
Math.random()
Something like 使用
Math.random()
东西
echo '<input type="button" value="Reload Page"
onClick="window.location.href = window.location.pathname&\'?t=\'&Math.random();">';
To reload from server use: 要从服务器重新加载,请使用:
window.location.reload(true)
Info: http://www.devguru.com/technologies/ecmascript/quickref/reload.html 信息: http : //www.devguru.com/technologies/ecmascript/quickref/reload.html
使用Math.random()将起作用,因此(new Date())。getTime()也将起作用。
instead of javascript why not link directly 而不是JavaScript,为什么不直接链接
<?php
echo "<a href='" . $_SERVER['PHP_SELF'] . "&=" . time() . "'>Reload Page</a>";
?>
instead? 代替?
Edit :: As i note I only suggest this because you included the sample php within your original post. 编辑::我注意到我只建议这样做,因为您在原始帖子中包含了示例php。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.