1

what is the proper way to make this work , its not targeting chrome with a different height

        if(franchise_id=="0000") {
          $('#aj_auction').css('height', '558px');
            if($.browser.chrome) {
              $('#aj_auction').css('height', '598px');
            }
        }
MShack
  • 642
  • 1
  • 14
  • 33
  • possible duplicate of [How to detect if a browser is Chrome using jQuery?](http://stackoverflow.com/questions/6339480/how-to-detect-if-a-browser-is-chrome-using-jquery) – Nikhil Aggarwal Jul 11 '15 at 19:46
  • saw that , but how would i do a if statement within this ? – MShack Jul 11 '15 at 19:52

3 Answers3

1

You can try $.browser.chrome to check browser

if(franchise_id=="0000") {
  if($.browser.chrome) {
      $('#aj_auction').css('height', '598px');
  }else{

      $('#aj_auction').css('height', '558px'); 

 }
}

Need to use Modernizr.

However, if you necessarily want to use $.browser property, you can do it using jQuery Migrate plugin (for JQuery >= 1.9 - in earlier versions you can just use it)

Bhavin Solanki
  • 4,740
  • 3
  • 26
  • 46
1

Check if it's chrome using userAgent

    var is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
    if(is_chrome){
        $('#aj_auction').css('height', '598px');
    }
Patel
  • 1,478
  • 1
  • 13
  • 24
0

Try to detect the browser first and apply that condition as follows :

$.browser.chrome = /chrom(e|ium)/.test(navigator.userAgent.toLowerCase()); 
if($.browser.chrome){
........
}

jQuery has removed $.browser from 1.9 and their latest release.But we can still use $.browser as a standalone plugin,link.

Hope this helps.

Krishna Chandran
  • 389
  • 3
  • 18