开发者

Turn off form fields autocomplete on browser back button for Internet Explorer

There are some questions that explain how to turn off the autocomplete feature for form fields however I have a specific problem here:

I've set the autocomplete="off" to both the the <form> and all form fields. I want to prevent the browser from prefilling the fields when the开发者_运维技巧 user returns from the forms target page to the original page (that contains the form) by using the browser back button. The form fields use some jQuery UI widgets that don't work with prefilled values. It's necessary that the user interacts with the form before submitting it.

This works as expected in Firefox, Chrome, Safari. However it doesn't work in Internet Explorer (I've tested versions 8 and 9). IE still fills out the fields when returning to the page via the browser's back button.

This is a static HTML page so I'm not able to perform some backend actions like for example setting random form field names/IDs.

What can I do?


<script type="text/javascript">
    window.onbeforeunload = function () {
        var f = document.getElementById('MyTextBox');
        f.textContent = ""; // or default values
    }
</script> 

Have you tried this to unload the data when leaving the page so it's not there when coming back?

I have the same problem unfortunately I can't get this solution going in ASP.NET.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜