Detecting if under a mobile webbrowser

Just starting out? Need help? Post your questions and find answers here.
User avatar
DjPoke
Posts: 22
Joined: Sat Dec 19, 2015 5:27 pm
Location: France (Corsica)
Contact:

Detecting if under a mobile webbrowser

Post 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
My Freewares here :
http://retro-bruno.fr/
Fred
Site Admin
Posts: 1820
Joined: Mon Feb 24, 2014 10:51 am

Re: Detecting if under a mobile webbrowser

Post 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.
User avatar
DjPoke
Posts: 22
Joined: Sat Dec 19, 2015 5:27 pm
Location: France (Corsica)
Contact:

Re: Detecting if under a mobile webbrowser

Post by DjPoke »

Thanks a lot !
I'm sorry, i make novice errors.
My Freewares here :
http://retro-bruno.fr/
Post Reply