<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>test</title> </head> <body> <input type="text" id="text" value=""> <input type="button" onclick="changeText()" value="点完刷新看看"> <script type="text/javascript"> function changeText(){ document.getElementById("text").value="我已经改变了"; } function reseta(){ document.getElementById("text").value="点完刷新看看"; } reseta(); </script> </body> </html>
正常情况下,这个刷新是可以让文本框恢复值的,而在IE8里面input的值修改后,刷新依然还是修改后的值,我的解决方法是:加setTimeout
//reseta(); setTimeout(reseta,200);