tags:

views:

38

answers:

5
+1  Q: 

Jquery if browser

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

MY Tooltip

$('.tooltip').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

+3  A: 

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/

Chuck Vose
A: 

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.

esqew
not working on ie 7 up....
vb mozilla
Like I said, check the regex.
esqew
+1  A: 

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().

calvinf
A: 

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 
      }
Hasu
A: 

How does this work

Dave
This is not an answer. Please delete it.
Peter Ajtai