js调用刷新界面的几种方式
名字不好起啊 人气:0有的时候需要手动调用来刷新界面,比如非动态切换的语言模式啊,风格样式啊什么的。
<!DOCTYPE html> <html> <head> <meta charset='utf-8'> </head> <body> <button onclick="click1()">location.reload();</button> <button onclick="click2()">history.go(0);</button> <button onclick="click3()"> location=location ;</button> <button onclick="click4()">location.assign(location) ;</button> <button onclick="click5()">location.replace(location) ;</button> <script> function click1 () { //刷新清缓存,相当于Ctrl+F5:location.reload(true) //普通刷新:location.reload() location.reload(); } function click2(){ history.go(0); } function click3(){ location=location; } function click4(){ location.assign(location) ; } function click5(){ location.replace(location) } </script> </body> </html>
加载全部内容