防止浏览器文本输入建议 [英] Preventing Browser Text Input Suggestions

查看:148
本文介绍了防止浏览器文本输入建议的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:

如何在网络表单字段/输入标签上停用浏览器自动填充?


我正在构建自己的本地搜索UI元素,在您输入时提供本地搜索建议。我遇到的问题是,当我专注于HTML文本输入元素我的浏览器(Safari,但可能发生在其他浏览器)显示其自己的文本建议基于我在过去键入的东西。



我的猜测是,这取决于ID或类的<输入>标签。所以可能,如果我将输入标签类更改为晦涩的东西,浏览器将不会提供任何建议。但是我想知道是否没有更优雅的方式...



一个相关的问题是关于文本字段突出发生在Safari中,当你专注于<输入>元素。当我在Facebook上填写表单时,我没有看到这个大纲。

解决方案

基于Gecko的浏览器支持一个标记属性, autocomplete。所以在你的< form> 标签中,你会把< form autocomplete =off> p>

更多: https://developer.mozilla.org/en/How_to_Turn_Off_form_Autocompletion



其他一些浏览器也支持此功能。我相信IE会尊重这一点。


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.

解决方案

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.

这篇关于防止浏览器文本输入建议的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆