code to check browser verison and alter url accordingly

Discussion in 'HTML' started by TheDragon, Dec 11, 2004.

  1. TheDragon

    TheDragon Guest

    I wish I could master this, When users brows my site, I would like them to
    get a browser optimised version, specific to their setup.

    I.e., a regular IE/Netscape users on a desktop/laptop gets the regular site.
    A user browsing from a pockepPC/Palm get a pocket optimised version
    a user browsing from a mobile phone, gets a wml version.

    Like this
    www.mysite.com - regular users
    www.mysite.com/pocket pocketpc users
    www.mysite/wap for mobile users..

    I know Google does this, because when I go their from my PPC, I get a small
    version, and the url is www.google.co.uk/palm/
    Tried to look at the code of the Google site, but there is nothing there to
    see of any relevance.


    Thanks in advance.
    TheDragon, Dec 11, 2004
    #1
    1. Advertising

  2. TheDragon

    paul Guest

    TheDragon wrote:

    > I wish I could master this, When users brows my site, I would like them to
    > get a browser optimised version, specific to their setup.
    >
    > I.e., a regular IE/Netscape users on a desktop/laptop gets the regular site.
    > A user browsing from a pockepPC/Palm get a pocket optimised version
    > a user browsing from a mobile phone, gets a wml version.
    >
    > Like this
    > www.mysite.com - regular users
    > www.mysite.com/pocket pocketpc users
    > www.mysite/wap for mobile users..
    >
    > I know Google does this, because when I go their from my PPC, I get a small
    > version, and the url is www.google.co.uk/palm/
    > Tried to look at the code of the Google site, but there is nothing there to
    > see of any relevance.
    >
    >
    > Thanks in advance.



    It's fairly easy if you have PHP support, there probably are other ways.
    http://www.edgehill.net/1/index.php?SCREEN=browser-detect.php

    <?php
    if (strpos($_SERVER["HTTP_USER_AGENT"], "MSIE") !== false) {
    ?>
    <center><b>You are using Internet Explorer, IDIOT!</b></center>
    <?php } else { ?>
    <center><b>You are not using Internet Explorer so you must be
    smart!!</b><br>
    (you are using:
    <?php echo $_SERVER["HTTP_USER_AGENT"];?>
    )</center>
    <?php } ?>
    paul, Dec 11, 2004
    #2
    1. Advertising

  3. TheDragon

    Jan Faerber Guest

    TheDragon wrote:

    > I wish I could master this, When users brows my site, I would like them to
    > get a browser optimised version, specific to their setup.
    >
    > I.e., a regular IE/Netscape users on a desktop/laptop gets the regular
    > site. A user browsing from a pockepPC/Palm get a pocket optimised version
    > a user browsing from a mobile phone, gets a wml version.
    >
    > Like this
    > www.mysite.com - regular users
    > www.mysite.com/pocket pocketpc users
    > www.mysite/wap for mobile users..
    >
    > I know Google does this, because when I go their from my PPC, I get a
    > small version, and the url is www.google.co.uk/palm/
    > Tried to look at the code of the Google site, but there is nothing there
    > to see of any relevance.
    >
    >
    > Thanks in advance.


    ..ogoO0ogl.
    http://www.webhostingtalk.com/archive/thread/350071-1.html
    http://www.240px.com/howto.htm
    http://www.palmone.com/us/software/webpro30/WebPro3_DeveloperGuide.pdf

    For a deeper answer click here:

    http://imgsrc.hubblesite.org/hu/db/1996/01/videos/a/formats/low_mpeg.mpg

    (;



    --
    Jan

    http://linux.janfaerber.com
    Jan Faerber, Dec 11, 2004
    #3
  4. TheDragon

    Kris Guest

    In article <>,
    "TheDragon" <> wrote:

    > I wish I could master this, When users brows my site, I would like them to
    > get a browser optimised version, specific to their setup.


    Author for the web, not for specific browsers and your problem goes away.

    --
    Kris
    <> (nl)
    Kris, Dec 11, 2004
    #4
  5. Jan Faerber wrote:

    > TheDragon wrote:
    >
    >> I wish I could master this, When users brows my site, I would
    >> like them to get a browser optimised version, specific to their
    >> setup.


    Is this really necessary any longer?

    >> I.e., a regular IE/Netscape users on a desktop/laptop gets the
    >> regular site. A user browsing from a pockepPC/Palm get a pocket
    >> optimised version a user browsing from a mobile phone, gets a wml
    >> version.

    <snip>

    > .ogoO0ogl.
    > http://www.webhostingtalk.com/archive/thread/350071-1.html


    Says use JavaScript. What do you do if it is disabled or unavailable?

    > http://www.240px.com/howto.htm


    Says: "The following basic Java code will work to seamlessly screen
    and redirect PocketPC users ..." Java code? <lol>

    > http://www.palmone.com/us/software/webpro30/WebPro3_DeveloperGuide.pdf


    Didn't read this .pdf.

    My opinion is that any correctly-designed site will work on all
    devices without resorting to sniffing shenanigans. Check your site in
    Opera, and choose "View > Small Screen" to test. My sites all work
    perfectly in that mode, with no trickery. A friend with a PDA confirms.

    --
    -bts
    -This space intentionally left blank.
    Beauregard T. Shagnasty, Dec 11, 2004
    #5
  6. TheDragon

    Jan Faerber Guest

    Beauregard T. Shagnasty wrote:


    >> http://www.palmone.com/us/software/webpro30/WebPro3_DeveloperGuide.pdf

    >
    > Didn't read this .pdf.


    It says:
    'PalmTM Web Pro 3.0 Developer Guide | Contents | Detecting Palm Web Pro
    access .... page 5'

    <q>
    Because handhelds typically have smaller screen sizes and other physical
    characteristics that make them differnet from desktop computers, you may
    want to optimize pages specifically for handhelds viewing. Your web server
    can detect Palm Web Pro access requests by looking for the browser's
    user-agent string. A simple server-side script can detect the access and
    display pages that work with the handheld's configuration.

    The user-agent string for Palm Web Pro 3.0 is:

    Mozilla/4.76 [en] (PalmOS; U; WebPro/3.0, <manufacturer ID>-<model ID>)

    where <manufacturer ID> and <model ID> are replaced with the appropriate ID
    codes.

    Tungsten(R)T3 example:

    Mozilla/4.76 [en] (PalmOS; U; WebPro/3.0; Palm-Arzl)

    Tungsten C example:

    Mozilla/4.76 [en] (PalmOS; U; WebPro/3.0; palm-MT64)

    The presence of the manufacturer ID and model ID in the user-agent string
    allows you to optionally send different content to different Palm handheld
    models. For information about model IDs for the various Palm handheld
    models, please visit the Palm developer support web site at
    pluggedin.palmone.com.

    If you have different version of the Web Pro browser such as v3.0.1b, the
    appropriate version number will be present in the user-agent string.
    </q>




    --
    Jan

    http://linux.janfaerber.com
    Jan Faerber, Dec 11, 2004
    #6
  7. While the city slept, TheDragon () feverishly typed...

    > I wish I could master this, When users brows my site, I would like
    > them to get a browser optimised version, specific to their setup.


    http://www.anybrowser.org/campaign/

    Cheers,
    Nige

    --
    Nigel Moss
    http://www.nigenet.org.uk
    Mail address not valid. , take the DOG. out!
    In the land of the blind, the one-eyed man is very, very busy!
    nice.guy.nige, Dec 11, 2004
    #7
  8. Jan Faerber wrote:
    > Beauregard T. Shagnasty wrote:
    >
    >>> http://www.palmone.com/us/software/webpro30/WebPro3_DeveloperGuide.pdf

    >>
    >> Didn't read this .pdf.

    >
    > It says: ...
    >
    > ... Your web server can detect Palm Web Pro access
    > requests by looking for the browser's user-agent string.


    ...which is unreliable. Easily forged in any number of browsers. <g>
    What page will it serve me if my UA says "I love palm trees but my
    browser is Snagglethorpe 3.0" ?

    I still say the easiest way is to write pages that work in all
    browsers rather than trying to sniff. Seems a pain to have to maintain
    three or four different sites, wouldn't y'all agree?

    --
    -bts
    -This space intentionally left blank.
    Beauregard T. Shagnasty, Dec 11, 2004
    #8
  9. TheDragon

    Jan Faerber Guest

    Beauregard T. Shagnasty wrote:

    > Jan Faerber wrote:
    >> Beauregard T. Shagnasty wrote:
    >>
    >>>> http://www.palmone.com/us/software/webpro30/WebPro3_DeveloperGuide.pdf
    >>>
    >>> Didn't read this .pdf.

    >>
    >> It says: ...
    >>
    >> ... Your web server can detect Palm Web Pro access
    >> requests by looking for the browser's user-agent string.

    >
    > ..which is unreliable. Easily forged in any number of browsers. <g>
    > What page will it serve me if my UA says "I love palm trees but my
    > browser is Snagglethorpe 3.0" ?
    >
    > I still say the easiest way is to write pages that work in all
    > browsers rather than trying to sniff. Seems a pain to have to maintain
    > three or four different sites, wouldn't y'all agree?
    >


    So the palm automatically redirects to www.google.com/palm - ?




    --
    Jan

    http://linux.janfaerber.com
    Jan Faerber, Dec 11, 2004
    #9
  10. Jan Faerber wrote:

    > So the palm automatically redirects to www.google.com/palm - ?


    Perhaps. I don't have one. Google probably has ample coders to
    maintain multiple versions of their sites, but this isn't something
    the average small shop should need to be involved in.

    Did you notice the "About" link on that page takes you right to their
    main site? <g> (in my browser)

    --
    -bts
    -This space intentionally left blank.
    Beauregard T. Shagnasty, Dec 11, 2004
    #10
  11. TheDragon

    paul Guest

    Beauregard T. Shagnasty wrote:
    > Jan Faerber wrote:
    >
    >> So the palm automatically redirects to www.google.com/palm - ?

    >
    >
    > Perhaps. I don't have one. Google probably has ample coders to maintain
    > multiple versions of their sites, but this isn't something the average
    > small shop should need to be involved in.



    I believe google uses php. They probably process the same data into
    multiple formats so don't really maintain multiple copies.
    paul, Dec 12, 2004
    #11
  12. paul wrote:

    > I believe google uses php. They probably process the same data into
    > multiple formats so don't really maintain multiple copies.


    I suppose that is possible; I use php, too. But due to the speed at
    which it operates, I'd guess it is something more robust, perhaps even
    compiled modules. No way to tell from here.

    Their main page has:

    <form action=/search name=f>

    --
    -bts
    -This space intentionally left blank.
    Beauregard T. Shagnasty, Dec 12, 2004
    #12
  13. TheDragon

    Toby Inkster Guest

    paul wrote:

    > I believe google uses php.


    I would be highly skeptical of such a claim.

    (IIRC Yahoo does though.)

    --
    Toby A Inkster BSc (Hons) ARCS
    Contact Me ~ http://tobyinkster.co.uk/contact
    Toby Inkster, Dec 12, 2004
    #13
  14. TheDragon

    TheDragon Guest

    You ever tried viewing a web page on a mobile phone, very difficult.

    What I am trying to achieve is a mini version of my site just for mobiles.
    There thay can download games ringtones etc.
    They could view a mini copy of the main site, but will much smaller
    graphics, and less of them.
    TheDragon, Dec 12, 2004
    #14
  15. TheDragon

    TheDragon Guest

    Thanks for the links. I tried to google, but got nowhere. I suppose i may be
    asking the wrong qustions, and getting naff results.

    The top link shows someone else asking the exack same question. So i know i
    am now not alone.
    TheDragon, Dec 12, 2004
    #15
  16. TheDragon

    Kris Guest

    In article <>,
    "TheDragon" <> wrote:

    > You ever tried viewing a web page on a mobile phone, very difficult.


    Please quote what you are replying to, it is the common practice in this
    group.

    Viewing a website on a mobile phone is not necessarily difficult. It is
    however *different*. Most of the sites I make have little difficulty
    being used on a mobile phone. These websites are built for the web, not
    for particular browsers.

    > What I am trying to achieve is a mini version of my site just for mobiles.


    If you can use 5 words instead of 10 to convey the same message, why
    would people with desktop browsers need to deal with 10 words?

    > There thay can download games ringtones etc.


    I usually download them using my desktop browser. Bluetooth can be a
    wonderful thing.

    > They could view a mini copy of the main site, but will much smaller
    > graphics, and less of them.


    They can disable graphics themselves to keep bandwidth fees low. You
    could supply a stylesheet for the handheld media type which replaces
    images for their alt attribute value, for browsers that support this.

    --
    Kris
    <> (nl)
    Kris, Dec 12, 2004
    #16
  17. TheDragon

    Philip Ronan Guest

    TheDragon wrote:

    > You ever tried viewing a web page on a mobile phone, very difficult.
    >
    > What I am trying to achieve is a mini version of my site just for mobiles.
    > There thay can download games ringtones etc.
    > They could view a mini copy of the main site, but will much smaller
    > graphics, and less of them.


    Search Google for "content negotiation".

    Basically what you need to do is check the "Accept" header in the HTTP
    request provided by the user agent. if it claims to prefer
    "text/vnd.wap.wml" over "text/html" then serve up the .wml content. Apache
    servers can do this automatically for you. YMMV on other systems.

    Checking for specific HTML user agents (e.g. Palm) isn't going to be quite
    as straightforward, and to be honest you might be better off producing a
    flexible design that works at all sizes, as others have suggested.
    Alternatively you could apply string matching to the "User-Agent" request
    header (which is probably what Google are doing). But bear in mind your algo
    will have to be updated regularly as new handheld HTML browsers come out.

    --
    phil [dot] ronan @ virgin [dot] net
    http://vzone.virgin.net/phil.ronan/
    Philip Ronan, Dec 12, 2004
    #17
  18. TheDragon

    paul Guest

    Toby Inkster wrote:
    > paul wrote:
    >
    >
    >>I believe google uses php.

    >
    >
    > I would be highly skeptical of such a claim.
    >
    > (IIRC Yahoo does though.)



    That's what my php instructor said (an old hippy at a big city community
    college). Surely they have a very powerful database server connected to
    whatever they are using.
    paul, Dec 12, 2004
    #18
  19. TheDragon

    TheDragon Guest

    "Philip Ronan" <> wrote in message
    news:BDE1F41F.26B78%...
    > TheDragon wrote:
    >
    >> You ever tried viewing a web page on a mobile phone, very difficult.
    >>
    >> What I am trying to achieve is a mini version of my site just for
    >> mobiles.
    >> There thay can download games ringtones etc.
    >> They could view a mini copy of the main site, but will much smaller
    >> graphics, and less of them.

    >
    > Search Google for "content negotiation".
    >
    > Basically what you need to do is check the "Accept" header in the HTTP
    > request provided by the user agent. if it claims to prefer
    > "text/vnd.wap.wml" over "text/html" then serve up the .wml content. Apache
    > servers can do this automatically for you. YMMV on other systems.
    >
    > Checking for specific HTML user agents (e.g. Palm) isn't going to be quite
    > as straightforward, and to be honest you might be better off producing a
    > flexible design that works at all sizes, as others have suggested.
    > Alternatively you could apply string matching to the "User-Agent" request
    > header (which is probably what Google are doing). But bear in mind your
    > algo
    > will have to be updated regularly as new handheld HTML browsers come out.
    >
    > --
    > phil [dot] ronan @ virgin [dot] net
    > http://vzone.virgin.net/phil.ronan/
    >
    >


    Thanks for this tip I will have a play. I am using IIS5 not Apache, but will
    give it a try.

    Thanks again.
    TheDragon, Dec 12, 2004
    #19
  20. TheDragon

    Toby Inkster Guest

    paul wrote:

    > That's what my php instructor said (an old hippy at a big city community
    > college).


    Then he is silly. If Google do use PHP it would only be for peripheral
    things. To implement the main Google search functionality in PHP would be
    entirely too inefficient.

    > Surely they have a very powerful database server connected to whatever
    > they are using.


    No. They have a pool of tens-of-thousands of low-powered run-of-the-mill
    Intel boxen.

    --
    Toby A Inkster BSc (Hons) ARCS
    Contact Me ~ http://tobyinkster.co.uk/contact
    Toby Inkster, Dec 12, 2004
    #20
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Brian Simmons
    Replies:
    2
    Views:
    663
    Brian Simmons
    Jul 19, 2007
  2. S_K
    Replies:
    1
    Views:
    798
    Alexey Smirnov
    Oct 18, 2007
  3. -berlin.de
    Replies:
    0
    Views:
    130
    -berlin.de
    Jun 30, 2007
  4. Why Tea

    How to append a file accordingly?

    Why Tea, Nov 26, 2007, in forum: Perl Misc
    Replies:
    10
    Views:
    159
  5. Rakhi
    Replies:
    1
    Views:
    109
    Erwin Moller
    Apr 3, 2008
Loading...

Share This Page