前些天在项目中遇到很奇怪的问题,网页的输入框莫名其妙变成黄色,当时在本地没有这个问题,但在客户那里就出现这个情况,非常的纳闷,最后查出来居然是GoogleToolBar的问题: 解决方案如下:
http://www.p3pwriter.com/LRN_181.asp
1.0 Browser HTML Input Elements
Browser input elements are an html element that has attributes such as name and value. These elements are also able to be styled using CSS attributes.
Lately some browsers have been displaying a yellow background on some of the form input elements.
Some users and programmers have begun to question if Microsoft has implemented new privacy standards to use yellow highlight for form input elements.
1.1 Google Toolbar
The Google toolbar is a popular browser add-on that makes searching the web easier. The toolbar also has a function that allows autofill of html input elements. When autofill is on (the default installation setting), the input boxes are styled to have a yellow background color.
1.2 What can I do to stop this?
If you are a user you can set the following: Options --> More --> Extras --> Automatically highlight fileds that autofill can fill, uncheck.
1.3 What can I do allow my web site visitors to see the background color I would like instead of the Google yellow?
The first option is to set the style of the input elements using the !important attribute of the css setting.
Alternately you could use a javascript program to reset the background color of all the form elements using the following script or something similar.
if(window.attachEvent)window.attachEvent("onload",resetStyles);
function resetStyles(){
unGoogle('INPUT');
unGoogle('SELECT');
}
function unGoogle(eleType){
var t=document.getElementsByTagName(eleType);
for(var i=0;i<t.length;i++){
t[i].attachEvent('onpropertychange',resetCSS);
t[i].style.backgroundColor='';
}
}
function resetCSS(){
var s=event.srcElement.style;
if(s.backgroundColor!='')s.backgroundColor='';
}