Page 1 of 1

Detecting if under a mobile webbrowser

Posted: Wed Jan 13, 2016 11:04 am
by DjPoke
I've found a code to detect mobile web-browsers, but after an adaptation, it doesn't seems to works on SB.
Can you take a look ?

I would like the event to be bind only if i'm not under a mobile, but my var "isMobile" always stay to 0.

Code: Select all

    isMobile.i = 0
    
    ! if(navigator.userAgent.match(/Android/i) || navigator.userAgent.match(/webOS/i) || navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPad/i) || navigator.userAgent.match(/iPod/i) || navigator.userAgent.match(/BlackBerry/i) || navigator.userAgent.match(/Windows Phone/i)) {
    !     v_isMobile = 1;
    ! }
    
    If isMobile = 0
      BindEvent(#PB_Event_SizeWindow, @SizeWindowHandler())
    EndIf

Re: Detecting if under a mobile webbrowser

Posted: Wed Jan 13, 2016 2:06 pm
by Fred
The variable needs to be in full lowercase when used in inline JS: v_ismobile. I strongly suggest to take a look to the generate spiderbasic.js file for a better overview of SB internal, it's easy to follow.

Re: Detecting if under a mobile webbrowser

Posted: Wed Jan 13, 2016 7:51 pm
by DjPoke
Thanks a lot !
I'm sorry, i make novice errors.