Check the browser type and version in jquery1.9

Source: Internet
Author: User

Today's project needs to customize the style of the drop-down box and introduce the plug-in. As a result, Firefox compatibility problems have emerged. I 'd like to say that I have never known it was a problem with Firefox, I always thought that my style may have been wrong. I checked my style for a long time, but I found that Google is normal. I checked the project that was useful in the past and found that this problem also exists, hookan ~ People have encountered this problem. It's okay, because people have not damaged the overall visual effect, and I cannot do it here, because div is used to simulate the drop-down box.

Problem: Use placeholder to display the description in the input box and change the placeholder text style. The font color is white and can be normally displayed on Google. Firefox will not work and Firefox will be light gray, later, I checked it online and said Google and Firefox have different definitions. These two sentences are used:

 
:-WebKit-input-placeholder {color: # FFF ;}
Input:-moz-placeholder {color:# FFF; }

It means that I also used it, and it was useless. I couldn't see the effect, and I couldn't see it with the review elements. I simply added a style and made all the fonts in uppercase, and the results were all in uppercase, the style application is on ~ I don't know what's wrong this time ~ After a hundred twists and turns, I realized that the previous projects were displayed in light gray, but a div is normally displayed in white, the other three inputs are displayed in gray, the design draft is white, and Google is also displayed normally. So I want to change the color of the text in the DIV to light gray, but it does not affect Google, I checked Firefox Google's hack. I want to say that they are just like one. There is nothing about their hack. I can't help but use a browser to detect it. $. browser, error... It turns out that jquery1.9 is used this time, and this method has been removed. You can only find other methods. It is useless to try many methods. Only the following is feasible.

Determine the browser type:
$. Browser. Mozilla =/Firefox/. Test (navigator. useragent. tolowercase ());
$. Browser. WebKit =/WebKit/. Test (navigator. useragent. tolowercase ());
$. Browser. Opera =/Opera/. Test (navigator. useragent. tolowercase ());
$. Browser. MSIE =/MSIE/. Test (navigator. useragent. tolowercase ());
The expression after the equal sign returns true/false, which can be directly used to replace the original $. browser. MSIE.

Check whether IE6 is used:
// Old
If ($. browser. MSIE & 7> $. browser. Version ){}
// New
If ('undefined' = typeof (document. Body. style. maxheight )){}

Check whether it is IE 6-8:
If (! $. Support. leadingwhitespace ){}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.