开发者

disable autocomplete/pre-populate in IE via HTML?

Demo link: http://elevation-inc.com/dev/test/ieform/

In IE 6/7/8 - if you enter a term into a simple input field, submit the form and then hit the back button - the input field retains the previously submitted term. If you then refresh the p开发者_JS百科age, the value is also retained.

How, via HTML, can this pre-population be disabled? We want no value to be in the input box on page load/domready.

We've already tried autocomplete='off' on both the form and input element, but the pre-population is still persisting.

Thanks in advance.


<input type="text" name="userid" autocomplete="off" /> works fine for me (the same goes with your form). Make sure you reload the page in between testing (CTRL + F5 for full refresh).


This is how IE works, but you can change the value with JavaScript

<body onload="document.getElementById('q').value = '';">
<form action="http://www.google.com/search" name="f" autocomplete="off">
    <input type="text" name="q" autocomplete="off" id="q"><input type="submit">
</form>


Well I guess it's a browser behaviour you can't bypass by html. You can do it in javascript however:

<script>
window.onload = function() { document.forms.f.q.value = ""; };
</script>

or if you don't want to wait for images to load (because window.onload will wait for that), you can use the document ready event, as described here. (it needs more tweaking to make it work across all browsers)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜