Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: browser detection, client or server?

  1. #1
    Join Date
    Nov 2009
    Beans
    183

    browser detection, client or server?

    Hello everyone!


    I am developing a website using CSS3 animations, video, canvas etc and the same website for mobile devices.


    So, depending on the browser the content varies. For example:


    If the user has a mobile browser the content is different.
    If the user is using IE, I can not show animations.
    Etc.....


    I know that this must be a stupid question, but I have read a lot on the web. Is it better to do the Browser detection with server side (PHP) or JavaScript??


    For what I have read, it seems to me that it is better to do in PHP, including files depending of the browser.


    Thank you very much!!!

  2. #2
    Join Date
    Apr 2008
    Beans
    507

    Re: browser detection, client or server?

    Definitely client-side. Also best to use a decent feature detection lib rather than sniffing the UA string (which is unreliable). Try here http://modernizr.com/
    Go you good thing!

  3. #3
    Join Date
    Nov 2009
    Beans
    183

    Re: browser detection, client or server?

    Hi myrtle190! thanks for reply. I have read your link about modernizr to perform browser detection on the client-side.

    This is what I can do with modernizr:

    Code:
    if(!Modernizr.cssanimations)  	window.location='nocss3/index.php';
    can't I? this is very useful for me!

    But also I need to do mobile detection. I have been reading
    about modernizr in the web, and it seems to me that I can not perform
    a mobile detection.

    How can I do that??
    Thank you very much!

  4. #4
    Join Date
    Sep 2006
    Beans
    8,627
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: browser detection, client or server?

    I would say the opposite: definitely server side!

    That takes out the complexities of trying to run scripting on clients that may or may not support your script and may even have scripting turned off. More of the security conscious people (or those tired of ads) will browse with javascript off. With the server side detection you have full control over what is server and how the selection is made.

  5. #5
    Join Date
    Nov 2009
    Beans
    183

    Re: browser detection, client or server?

    Hi Lars Noodén! thanks for reply! I agree with you. But I have read that it is possible to fake the user agent of the client browser... What about that?

  6. #6
    Join Date
    Aug 2010
    Location
    Lancs, United Kingdom
    Beans
    1,588
    Distro
    Ubuntu Mate 16.04 Xenial Xerus

    Re: browser detection, client or server?

    Quote Originally Posted by chuchi View Post
    But I have read that it is possible to fake the user agent of the client browser... What about that?
    Why is that a problem? If a user tells you they are using IE when they are not, by means of faking the user agent, and you deliver content tailored for IE, then the user has got what they asked for.

  7. #7
    Join Date
    Sep 2006
    Beans
    8,627
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: browser detection, client or server?

    Quote Originally Posted by spjackson View Post
    Why is that a problem? If a user tells you they are using IE when they are not, by means of faking the user agent, and you deliver content tailored for IE, then the user has got what they asked for.
    Agreed. If the user agent is faking the identifications string, it means that the client is prepared to function as that browser and will work if your site treats it as such. Think of it as one form of customizing the browser. People really do spend time customizing their browsers to get them working the way they like it, even if not all modify their browser identification strings.

  8. #8
    Join Date
    Jul 2007
    Location
    Poland
    Beans
    4,499
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: browser detection, client or server?

    +1
    respect the user's configuration, don't double guess him, take the data his browser sends at face value.
    And one more thing: don't be a control freak with pixel perfect layouts that break when user changes default font size (some people have poor sight etc) in browser prefs or forces his own set of fonts (because he can, that's why ). Graceful degradation all the way.
    if your question is answered, mark the thread as [SOLVED]. Thx.
    To post code or command output, use [code] tags.
    Check your bash script here // BashFAQ // BashPitfalls

  9. #9
    Join Date
    Nov 2009
    Beans
    183

    Re: browser detection, client or server?

    I agree with all of you. Thank you very much for your help, it has been very helpful for me!!!

    Now I am using WURFL to browser detection on the server. But once installed, it takes more than 10MB!!! do you know other libraries for browser detection??

  10. #10
    Join Date
    Sep 2006
    Beans
    8,627
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: browser detection, client or server?

    I'm not familiar with WURFL. Do you have a link? I also realize that PHP libraries have a reputation for being unfinished and incomplete but maybe there is something there that can be used instead.

    However, there's really only one browser series that is problematic so why not let it detect itself?

    Code:
    <!--[if IE]>
          @import url("msie.css");
    <![endif]-->
    The above is legitimately a comment so real browsers will just ignore it. And if you design the XHTML + CSS right, the older browsers will still have something to render even if not as pretty. The principle is called degrade gracefully or something like that.

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •