[英]onclick refresh but not from cache?
我有這個按鈕來刷新頁面
echo '<input type="button" value="Reload Page"
onClick="window.location.href = window.location.pathname;">';
確保不從緩存中讀取頁面的最簡單方法是什么? 使用Math.random()
東西
echo '<input type="button" value="Reload Page"
onClick="window.location.href = window.location.pathname&\'?t=\'&Math.random();">';
要從服務器重新加載,請使用:
window.location.reload(true)
信息: http : //www.devguru.com/technologies/ecmascript/quickref/reload.html
使用Math.random()將起作用,因此(new Date())。getTime()也將起作用。
而不是JavaScript,為什么不直接鏈接
<?php
echo "<a href='" . $_SERVER['PHP_SELF'] . "&=" . time() . "'>Reload Page</a>";
?>
代替?
編輯::我注意到我只建議這樣做,因為您在原始帖子中包含了示例php。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.