1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Newbie with Javascript

Discussion in 'JavaScript' started by Rayj00, Sep 14, 2020.

  1. #1
    I am fairly new with programming with Javascript. I'm working on a website that I need to know if access to my website is from a mobile or not. So, my question is how do I code it to find out it the website visitor is using a mobile device or not?
    SEMrush
    Reason is I will be playing live streaming video and will need to size the video based on whether a mobile or not.

    Appreciate the responses.

    Ray
     
    Rayj00, Sep 14, 2020 IP
    SEMrush
  2. sarahk

    sarahk iTamer Staff

    Messages:
    26,377
    Likes Received:
    3,930
    Best Answers:
    111
    Trophy Points:
    665
    #2
    Hi

    Your browser will have a thing called "Development Tools". The easiest way to find it is to do a right mouse click over your page and select "inspect" from the menu options.

    upload_2020-9-15_9-41-24.png

    Once in there you'll find a lot of information that will probably be a bit overwhelming. What you're looking for is up in the top left-hand corner (typically, may vary a bit between browsers).

    upload_2020-9-15_9-43-19.png

    Find the symbol I've circled and your page will shrink to a default phone size. The menu at the top will let you pick different phone and tablet options.

    upload_2020-9-15_9-44-36.png


    FWIW this is a straight HTML question and nothing to do with javascript.
     
    sarahk, Sep 14, 2020 IP
  3. Rayj00

    Rayj00 Greenhorn

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    11
    #3
    Maybe you misunderstand. I need a Javascript solution to determine what kind of device is accessing my site. I need my server to determine if access to my website is from a mobile or not and then adjust the video size.
     
    Rayj00, Sep 15, 2020 at 8:00 AM IP
  4. sarahk

    sarahk iTamer Staff

    Messages:
    26,377
    Likes Received:
    3,930
    Best Answers:
    111
    Trophy Points:
    665
  5. qwikad.com

    qwikad.com Illustrious Member Affiliate Manager

    Messages:
    6,423
    Likes Received:
    1,379
    Best Answers:
    24
    Trophy Points:
    400
    #5
    Why would you want to do this using javascript? Just make your site responsive / fluid and the video will adjust its size to whatever screen automatically.
     
    qwikad.com, Sep 16, 2020 at 5:05 AM IP
    deathshadow and sarahk like this.
  6. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,375
    Likes Received:
    1,853
    Best Answers:
    245
    Trophy Points:
    515
    #6
    as @qwikad.com said, NOT JavaScript's job.

    That's layout. That's CSS' job. At MOST you would/should have an extra DIV to use the padding trick to force the aspect ratio to stay correct if the video is in a non-scaling container. (like the iframe youtube favors).

    Don't just dive for JavaScript as the answer to all your problems, generally that just shows you don't know enough HTML or CSS to be using JS in the first place.
     
    deathshadow, Sep 16, 2020 at 5:17 PM IP