默認情況下大多數的瀏覽器都會緩存input輸入框的值,當輸入框獲取焦點時緩存值就會出現,我們只能通過清除瀏覽器的緩存來清除輸入框的緩存值,這裏介紹兩種去掉輸入框緩存的方法:
input 的屬性autocomplete 默認爲on 其含義代表是否讓瀏覽器自動記錄之前輸入的值 很多時候,需要對客戶的資料進行保密,防止瀏覽器軟件或者惡意插件獲取到 可以在input中加入autocomplete="off" 來關閉記錄
1.方法一
在不想使用緩存的input中添加autocomplete="off";
例如:<input
<span style="color:#000000;"><input type="text" autocomplete="off"></span>
2.方法二
在input輸入框所在的form標籤中添加autocomplete="off";
<form action="#" autocomplete="off">
<input type="text" name="name" />
</form>
3.方法三 不讓頁面讀取緩存數據
<meta http-equiv= "Pragma" content= "no-cache" />
<meta http-equiv= "Cache-Control" content= "no-cache" />
<meta http-equiv= "Expires" content= "0" />