The code is as follows:
if(/msie/.test (Navigator.userAgent.toLowerCase ()) && $.browser.version.slice (0,3) <Ten) { $('Input[placeholder]'). each (function () {varInput = $ ( This); $ (input). val (Input.attr ('placeholder')); $ (input). focus (function () {if(Input.val () = = Input.attr ('placeholder') {input.val ("'); } }); $ (input). blur (function () {if(Input.val () = ="'|| Input.val () = = Input.attr ('placeholder') {input.val (input.attr ('placeholder')); } }); }); }
which
$.brower.msie = /msie/.test (navigator.userAgent.toLowerCase ()) //$.brower jquery1.90 above is removed
Jquery 1.9. More than 0 version extensions use the $.browser method
Because of jquery 1.9.0 or later jquery removed support for $.browser and used $.support to determine the browser type. Cause many previous plugins to error
"Uncaught typeerror:cannot Read Property ' Msie ' of undefined".
There are many solutions on the Internet, such as:
To determine the browser type:
[HTML]View PlainCopy
- <span style= "White-space:pre" > </span>$
- $
- $.browser.opera = /opera/.test ( Navigator.userAgent.toLowerCase ());
- $ .browser.msie = /msie/.test (Navigator.userAgent.toLowerCase ());
The expression after the number returns is True/false, which can be used to replace the original $.browser.msie and so on.
Check if it is IE6:
Old
[HTML]View PlainCopy
- <span style="White-space:pre"> </span>if ($.browser.msie && 7 > $.browser.version) {}
New
[HTML]View PlainCopy
- <span style="White-space:pre"> </span>if (' undefined ' = = typeof ( document.body.style.maxHeight)) {}
Check if it is IE 6-8:
[HTML]View PlainCopy
- <span style="White-space:pre"> </span>if (!$.support.leadingwhitespace) {}
**************************************************************************
The idea below is to use jquery's inheritance mechanism to extend the jquery 1.11.1 version to support the $.browser method, which is compatible with the previous component's purpose.
[HTML]View PlainCopy
- Jquery.extend ({
- Browser:function ()
- {
- Var
- Rwebkit =/(WebKit) \ ([\w.] +)/,
- Ropera =/(opera) (?:. *version)? [ \/] ([\w.] +)/,
- Rmsie =/(MSIE) ([\w.] +)/,
- Rmozilla =/(Mozilla) (?:. * RV): ([\w.] +))?/,
- browser = {},
- ua = window.navigator.userAgent,
- Browsermatch = uamatch (UA);
- if (Browsermatch.browser) {
- Browser[browsermatch.browser] = true;
- browser.version = browsermatch.version;
- }
- return {Browser:browser};
- },
- });
- function Uamatch (UA)
- {
- ua = ua.tolowercase ();
- var match = rwebkit.exec (UA)
- || Ropera.exec (UA)
- || Rmsie.exec (UA)
- || Ua.indexof ("compatible") < 0 && rmozilla.exec (UA)
- || [];
- return {
- BROWSER:MATCH[1] | | "",
- VERSION:MATCH[2] | | "0"
- };
- }
Save the above code for jquery-browser.js use.
Input placeholder compatible with IE10 below