PHP/HTML/CSS - If FireFox, If Chrome, If Safari

后端 未结 4 596
迷失自我
迷失自我 2021-02-04 07:32

Is there a simple conditional statement, css command, html, jquery, javascript or simple PHP dynamic way of detecting the current browser?


           


        
4条回答
  •  Happy的楠姐
    2021-02-04 07:50

    Using javascript:

    navigator.appCodeName
    

    Stores the browser codename:

    navigator.appName
    

    Is the name of the browser.

    But I would recommend using jQuery for more efficiency and less headaches:

    if ($.browser.webkit) {
       $("#div ul li").css( "display","inline-table" );
    } else if ( $.browser.msie ) {
       $("#div ul li").css( "display","inline" );
    } else {
       $("#div ul li").css( "display","inline-table" );
    }
    

    EDIT: According to jQuery.com:

    • webkit (Chrome and Safari)

    • safari (deprecated)

    • opera

    • msie (Internet Explorer)

    • mozilla (Firefox)

    Source: JQuery Site

提交回复
热议问题