测试: chrome,火狐浏览器,360浏览器,IE9
测试说明:火狐浏览器,IE9点击《刷新》,input的内容都不会清空
<html>
<body>
<input type="button" value="1" onclick="refresh1()">
<input type="button" value="2" onclick="refresh2()">
<input type="button" value="3" onclick="refresh3()">
<input type="button" value="4" onclick="refresh4()">
<input type="button" value="5" onclick="refresh5()">
<input type="button" value="6" onclick="refresh6()">
<input type="button" value="7" onclick="refresh7()">
<input type="button" value="8" onclick="refresh8()">
<br><br>
<input type="text">
</body>
<html>
<script type="text/javascript">
function refresh1(){
history.go(0);
//ie9无效
//火狐有刷新效果,但input内容不刷新
}
function refresh2(){
location.reload();
//火狐有刷新效果,但input内容不刷新
}
function refresh3(){
location = location;
}
function refresh4(){
location.assign(location);
}
function refresh5(){
document.execCommand('Refresh')
//ie9无效
//chrome无效
//火狐无效
//360无效
}
function refresh6(){
window.navigate(location);
//chrome无效
//火狐无效
//360无效
}
function refresh7(){
location.replace(location);
}
function refresh8(){
document.URL = location.href;
//chrome无效
//360无效
//火狐无效
}
</script>