Preventing Browser Text Input Suggestions [duplicate]

霸气de小男生 提交于 2019-12-19 05:01:24

问题


Possible Duplicate:
How do you disable browser Autocomplete on web form field / input tag?

I am building my own local search UI element that gives local search suggestions as you type. The problem I am having is that when I focus on the html text input element my browser (Safari, but could happen in other browsers) displays its own text suggestions based on things that I've typed in the past.

My guess is that this is dependent on the ID or Class of the < input > tag. So probably, if I change the input tag class to something obscure, the browser will not have any suggestions to offer. But I wonder if there isn't a more elegant way...

A related issue is about text field highlighting that happens in Safari when you focus on the < input > element. When I am filling up a form on Facebook, I don't see this outline. It would be great to hear if someone knows how to handle those two issues.


回答1:


Gecko-based browsers support a tag attribute called "autocomplete". So in your <form> tag you would put <form autocomplete="off">.

More here: https://developer.mozilla.org/en/How_to_Turn_Off_form_Autocompletion

Some other browsers have support for this as well. I believe IE will honor this.



来源:https://stackoverflow.com/questions/783573/preventing-browser-text-input-suggestions

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!