开发者

Jquery if browser

I am using a tooltip I got a positioning error on ie. I put a jquery browser code

MY Tooltip

$('.tooltip'开发者_如何学Python).tooltip({
    position: "bottom center"
  });

Then I want to add an argument like this

 $.browser.msie({
    // I wanted to add tooltip setting here
  });

How can I do that? please help


Not the best idea to detect the browser instead of the capabilities but I'm not one to frown and not give an answer. Use the jQuery Browser plugin:

http://api.jquery.com/jQuery.browser/


If you want to give special instructions for every version of IE, use the following:

if($.browser.msie){
  //ie tooltip code
} else {
  //default tooltip code
}

You can narrow it down further by version number. As others have suggested, look at the jQuery API documentation for $.browser().

Update:

This API ($.browser) was removed in jQuery 1.9. The recommended approach to building web applications is to use feature detection to determine what features a browser supports. Libraries such as Modernizr help with this.


try like this

if (navigator.userAgent.indexOf("Opera")>=0)

{
// your code for opera
}

if (navigator.userAgent.indexOf("MSIE")>=0)
{ 
// for IE
} 
if (navigator.userAgent.indexOf("Mozilla")>=0)
{
    //for firefox
}

or

if (document.all) { 
        //for IE
       } else { 
        // or other 
      }


You should try something like this:

if (navigator.userAgent.match("/MSIE/")) {
    // code for IE here
} else {
    // code for everyone else
}

I don't normally use regex, so it could be wrong. Any regex pattern will work for the match() method.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜