Detect iPhone Browser

前端 未结 6 1012
离开以前
离开以前 2020-12-05 08:59

is there a script to detect, if the visitor use iphone (whatever it\'s browser, may iphone Safari, iPhone for Opera or etc.)?

Then will shutdown some some of my Java

6条回答
  •  生来不讨喜
    2020-12-05 09:17

    searching on the net there are two common ways of achieving this. My favorite though is in PHP its just so clean? wow. :D

    In PHP you can write

    
    

    and in javascript you can write

    var agent = navigator.userAgent;
    var isIphone = ((agent.indexOf('iPhone') != -1) || (agent.indexOf('iPod') != -1)) ;
    if (isIphone) {
        window.location.href = 'http://www.yourwebsite.com/phone';
    }
    

    Hope that helps.

    PK

提交回复
热议问题