code to check browser verison and alter url accordingly

T

TheDragon

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.
 
P

paul

TheDragon said:
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 } ?>
 
J

Jan Faerber

TheDragon said:
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

(;
 
K

Kris

TheDragon said:
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.
 
B

Beauregard T. Shagnasty

Is this really necessary any longer?

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

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

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.
 
J

Jan Faerber

Beauregard T. Shagnasty wrote:

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>
 
B

Beauregard T. Shagnasty

Jan said:
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?
 
J

Jan Faerber

Beauregard said:
..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 - ?
 
B

Beauregard T. Shagnasty

Jan said:
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)
 
P

paul

Beauregard said:
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.
 
B

Beauregard T. Shagnasty

paul said:
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>
 
T

TheDragon

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.
 
T

TheDragon

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.
 
K

Kris

TheDragon said:
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.
 
P

Philip Ronan

TheDragon said:
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.
 
P

paul

Toby said:
paul wrote:




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.
 
T

TheDragon

Philip Ronan said:
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.

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

Thanks again.
 
T

Toby Inkster

paul said:
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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top