Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > browser detection and redirection

Reply
Thread Tools

browser detection and redirection

 
 
jaydev
Guest
Posts: n/a
 
      10-23-2006
Hi,

I am looking for code to detect and redirect to the corresponding
browser download page if the clients uses old version, could anyone
have a sample code for this?
I want to use the following version browser only, if they are other
types I need to redirect to there download page.
Internet Explorer version 5.0and above
Netscape Navigator version 7.0 and above
Mozilla version 1.3 and above
Opera version 7.0 and above
Safari/OmniWeb version 4.5 and above
Konqueror version 3.2 and above


Appreciate any help

Thanks,
Jay

 
Reply With Quote
 
 
 
 
Beauregard T. Shagnasty
Guest
Posts: n/a
 
      10-23-2006
jaydev wrote:

> I am looking for code to detect and redirect to the corresponding
> browser download page if the clients uses old version, could anyone
> have a sample code for this?


Browser sniffing is oft-mentioned as "doomed to failure."

> I want to use the following version browser only, if they are other
> types I need to redirect to there download page.


Normally, if you write a good site to begin, you won't have to restrict
your audience to a specific set of browsers.

> Internet Explorer version 5.0and above

...the latest is IE 7, and it is only usable by XP SP2 people. What about
W95/W98/ME/Win2K people?

> Netscape Navigator version 7.0 and above

...if you talk them into v 8.n, they will lose their email client.

> Mozilla version 1.3 and above

...the latest version of the suite is SeaMonkey.

And my User Agent string says:
Mozilla/6.0 (Starship Enterprise NCC-1701)

What will you do then?

--
-bts
-Motorcycles defy gravity; cars just suck
 
Reply With Quote
 
 
 
 
=?ISO-8859-1?Q?G=E9rard_Talbot?=
Guest
Posts: n/a
 
      10-23-2006
jaydev wrote :
> Hi,
>
> I am looking for code to detect and redirect to the corresponding
> browser download page if the clients uses old version, could anyone
> have a sample code for this?


Hello jaydev,

You have an interesting and worthy post in there. It's definitely a good
question.

> I want to use the following version browser only, if they are other
> types I need to redirect to there download page.
> Internet Explorer version 5.0and above
> Netscape Navigator version 7.0 and above
> Mozilla version 1.3 and above
> Opera version 7.0 and above


I would not bother trying to detect Opera 7.x users: there are very few
users using Opera 7.x since they usually upgrade to the latest Opera
version all by themselves. It's MSIE 5.x, MSIE 6 users which would be
worth detecting and who are most likely to be sensitive to issues of
upgrading or migrating/switching to another browser name.

> Safari/OmniWeb version 4.5 and above


Safari and OmniWeb upgrades are not free if I'm not wrong. So, here,
it's kinda difficult, delicate to tell them to upgrade. I think it's not
worth it otherwise it's not ok to annoy them, mainly for that reason.

> Konqueror version 3.2 and above


You have to wonder if Konqueror users upgrade to the latest stable
Konqueror release available by themselves and, if not, why and if their
numbers (visits at your site) are worth the trouble to detect them (via
javascript or otherwise).

>
>
> Appreciate any help
>
> Thanks,
> Jay



For any IE users, I think it is worth the efforts to invite such users
to either upgrade or to switch.

For other users, maybe just a link to a specific page listing where they
can get the latest version of their own browser name (and in such
webpage, telling them that browser upgrade is easy, free and will not
lose their profile info, bookmarks, emails, etc.. some people still
believe that upgrading browser version will make them lose their data
like bookmarks, preferences, etc.) would be good enough. What I mean
here is that, for instance, there are so few, so little Firebird users,
Phoenix users that it is not worth the problem to detect these users.

For NS 4.x users, I believe NS 4.x users are people who are not able to
perform browser upgrades by themselves and are going to actually upgrade
when they upgrade their computers or os: so, maybe it's not worth it.
Anyway, there are very few NS 4.x users on the web.

For any IE 5.x and IE 6 browsers, I suggest use of conditional comment:

<!--[if lte IE 6]>
<p>Some useful, relevant text, your speech here ...
<a href="http://www.microsoft.com/windows/ie/default.mspx">Download
Internet Explorer 7</a></p>
<![endif]-->

or

<!--[if lte IE 6]>
<p>You're using an old Internet Explorer version which is known to be
prone to spywares, to have unpatched security weaknesses and to make
computers unsafe. For best security and better usability, please
consider switching to a better browser. Visit <a
href="http://browsehappy.com/"><img
src="http://browsehappy.com/buttons/bh_185x75.gif" width="185"
height="75 alt="Browse Happy" style="vertical-align: bottom;"></a> for
explanations and assistance.</p>
<![endif]-->


More on this:

http://msdn.microsoft.com/workshop/a...rdetection.asp

I do **__not__** recommend user agent string detection: it's known to be
difficult to implement, unreliable and unmanageable in the long run.

Browser identification approach: not best, not reliable
Object/Feature support detection approach: best, most reliable
http://www.mozilla.org/docs/web-deve...evCrossBrowser

I personally believe people should prefer Firefox 2.0 or Opera 9.1
instead of choosing IE 7. This is also a very defendable decision. Or
you could even put a "browse happy" link/button/banner instead for IE
visitors and leave the whole decision up to the visitor.
http://browsehappy.com/

Then, the detection would / could go like :


<!--[if gt IE 6]>
<p>You're using Internet Explorer which is a browser known to have an
history of security concerns (to be prone to spywares, to have unpatched
security weaknesses, to make computers unsafe). I do not recommend the
use of Internet Explorer due to its relatively poor standards support
and security record, as well as its history of abandoning development
efforts. For all these reasons, I recommend switching to another browser
like <a href="http://www.opera.com/download/">Opera 9.1</a> or <a
href="http://www.mozilla.com/firefox/">Firefox 2.0</a> which are
available in many languages. Also, you may want to visit <a
href="http://browsehappy.com/"><img
src="http://browsehappy.com/buttons/bh_185x75.gif" width="185"
height="75 alt="Browse Happy" style="vertical-align: bottom;"></a> for
explanations and assistance.</p>
<![endif]-->

Downloadable Promotional graphics from Browser Happy
http://browsehappy.com/badges/

For Netscape Navigator, Mozilla, Phoenix, Firebird, Firefox 1.0.x users,
you will need to rely on userAgent string detection. If you decide to go
for this (if you have assessed that it's worth the trouble to detect
these users and then to invite them to upgrade), then you will need to
detect in the correct order navigator.product, navigator.vendor (and
possibly navigator.vendorSub too), navigator.productSub.

I would first try to detect Phoenix users, Firebird users and Firefox
1.0.x users. All Netscape users (NS 7.x, NS 8.x) could be also detected too.

if(navigator.product == "Gecko" && navigator.productSub &&
navigator.productSub > "20060201")
/* I don't think it's acceptable or justified to annoy people using a
less than 6 months old browser version */
{
if(navigator.vendor && possibly navigator.vendorSub=="Netscape")
{
...more code to develop...
}
else if()
{
...more code to develop...
};
}

Gérard
--
remove blah to email me
 
Reply With Quote
 
Jukka K. Korpela
Guest
Posts: n/a
 
      10-23-2006
Scripsit Gérard Talbot:

> jaydev wrote :
>> Hi,
>>
>> I am looking for code to detect and redirect to the corresponding
>> browser download page if the clients uses old version, could anyone
>> have a sample code for this?

>
> Hello jaydev,
>
> You have an interesting and worthy post in there. It's definitely a
> good question.


Well, it might be a good _question_. The correct _answer_, though, is that
such efforts are a waste of everyone's time, and worse.

The page author would just upset and throw out some part of potential users.
If he somehow managed to make someone update his browser, this would still
distract from the site's own content.

Besides, the detection is bound to fail, and the redirects are bound to take
users to wrong pages. Maybe not immediately, but next month or next year. If
you can make me believe that authors who write browser-sniffing and
browser-redirection code will actually _maintain_ the monstrosity they
create, you might just as well try making me believe in elves, Santa Claus,
the Great Pumpkin, and even politicians' promises before elections.

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/

 
Reply With Quote
 
=?ISO-8859-1?Q?G=E9rard_Talbot?=
Guest
Posts: n/a
 
      10-23-2006
Beauregard T. Shagnasty wrote :
> jaydev wrote:
>
>> I am looking for code to detect and redirect to the corresponding
>> browser download page if the clients uses old version, could anyone
>> have a sample code for this?

>
> Browser sniffing is oft-mentioned as "doomed to failure."
>


We agree.

Browser identification approach (aka "browser sniffing"): not best, not
reliable approach
Using Object/Feature support detection approach: best and overall most
reliable
http://www.mozilla.org/docs/web-deve...evCrossBrowser

>> I want to use the following version browser only, if they are other
>> types I need to redirect to there download page.

>
> Normally, if you write a good site to begin, you won't have to restrict
> your audience to a specific set of browsers.
>


Jay wants to invite people and to assist people using old browsers into
upgrading their browser versions. This is a perfectly valid attitude,
especially in this particular time period where Internet Explorer 7 has
been very recently released, Firefox 2.0 will be out in a few days and
Opera 9.1 will be released in a few days. Any/all respectable web author
wants people using old, buggy, unsecure, non-recommendable,
non-compliant web standards browsers (like MSIE 6) to upgrade to the
best, free, available browser out there.

>> Internet Explorer version 5.0and above

> ..the latest is IE 7, and it is only usable by XP SP2 people. What about
> W95/W98/ME/Win2K people?
>
>> Netscape Navigator version 7.0 and above

> ..if you talk them into v 8.n, they will lose their email client.
>


Good point. You normally would want a NS 7.x user to upgrade to the
latest available Seamonkey 1.x release.

>> Mozilla version 1.3 and above

> ..the latest version of the suite is SeaMonkey.
>


Correct. Again, good point.

> And my User Agent string says:
> Mozilla/6.0 (Starship Enterprise NCC-1701)
>
> What will you do then?


Good point... but only a minority of users "play" with their userAgent
identification string like you.

{
"Another major problem with this approach is that the browser identity
can be 'spoofed' because, in many modern browsers, the
navigator.appVersion and navigator.userAgent string properties are user
configurable strings. For example,

* Firefox 1.x users and users of any/all Mozilla-based browsers can
customize the "general.useragent.*" string properties to any value.
* Opera 6+ allows users to set the browser identification string
via a menu
* MSIE uses the Windows registry
* Safari and Icab browsers mask their browser identity under
Internet Explorer or Netscape labels
}

which is why browser identification based on userAgent string detection
is not reliable.

http://www.mozilla.org/docs/web-deve...l#BrowserIdent

One way to work around this problem would be to know which property or
method has been recently implemented in recently released Gecko-based
browsers.

For Opera 9, I recommend

if(window.opera && window.addEventListener && document.body.textContent)
[needs to be tested]
DOM 3 Core textContent attribute was implemented in Opera starting with
Opera 9.

For recent Gecko-based browsers (Seamonkey 1.0.?, Firefox 2):

if(window.netscape && document.compatMode &&
document.documentElement.createSVGAngle)
[I have not tested this one; maybe there is a better way]

Finally, a very safe, sound, respectable policy would be to add a link to

Why update?
http://www.upsdell.com/BrowserNews/why.htm

to

Find browsers
http://www.upsdell.com/BrowserNews/find.htm

and to
Browse Happy
http://browsehappy.com/

or possibly to

Alternative Browser Alliance
List of Alternative Web Browsers
http://www.alternativebrowseralliance.com/browsers.html
(personally, I would not recommend NS 8.x and I would definitely not
recommend K-meleon 1.x to newbies)

Gérard
--
remove blah to email me
 
Reply With Quote
 
Beauregard T. Shagnasty
Guest
Posts: n/a
 
      10-24-2006
Gérard Talbot wrote:

> Jay wants to invite people and to assist people using old browsers
> into upgrading their browser versions.


I wasn't sure that is what he meant, as he included "I want to use the
following version browser only, if they are other types I need to
redirect to there download page."

...which made me think he was designing pages that would not work in
older browsers. You could be right, let's ask him.

I love it when I go to a site with Opera or Firefox and am presented
with a page that tells me "you need to upgrade to Internet Explorer 5.0
or better". So I change the UA string to "IE6.0 WinXP" and it lets me
right in. As if I want to upgrade to a seven year old browser...

--
-bts
-Motorcycles defy gravity; cars just suck
 
Reply With Quote
 
=?ISO-8859-1?Q?G=E9rard_Talbot?=
Guest
Posts: n/a
 
      10-24-2006
Beauregard T. Shagnasty wrote :
> Gérard Talbot wrote:
>
>> Jay wants to invite people and to assist people using old browsers
>> into upgrading their browser versions.

>
> I wasn't sure that is what he meant, as he included "I want to use the
> following version browser only, if they are other types I need to
> redirect to there download page."
>


I think he meant webpages like

http://www.microsoft.com/windows/ie/default.mspx
http://www.opera.com/download/
http://browser.netscape.com/ns8/
http://www.mozilla.org/projects/seamonkey/
http://www.mozilla.com/firefox/
http://www.icab.de/dl.php
etc.


> ..which made me think he was designing pages that would not work in
> older browsers. You could be right, let's ask him.
>


Yes, he may have misworded all that.

> I love it when I go to a site with Opera or Firefox and am presented
> with a page that tells me "you need to upgrade to Internet Explorer 5.0
> or better".


Sometimes, I have been served such kind of message. Not often though.
The web is changing. Slowly but it is changing.

> So I change the UA string to "IE6.0 WinXP"


Do you know of a webpage that describes exactly (step by step) how to
modify the registry files to do this? I'm still searching...

and it lets me
> right in. As if I want to upgrade to a seven year old browser...
>


Sites which offer you to upgrade to IE5 are for sure bad sites,
unmanaged sites.

Gérard
--
remove blah to email me
 
Reply With Quote
 
Beauregard T. Shagnasty
Guest
Posts: n/a
 
      10-24-2006
Gérard Talbot wrote:

> Beauregard T. Shagnasty wrote :
>> So I change the UA string to "IE6.0 WinXP"

>
> Do you know of a webpage that describes exactly (step by step) how to
> modify the registry files to do this? I'm still searching...


To change the UA string? With Firefox, it is as simple as selecting one
in the dropdown that comes with the PrefBar extension.

http://prefbar.mozdev.org/
and a screen shot of the Customize dialog:
http://k75s.home.att.net/images/prefbar.png

Normally, I leave it set to "Real UA" of course.

--
-bts
-Motorcycles defy gravity; cars just suck
 
Reply With Quote
 
=?ISO-8859-1?Q?G=E9rard_Talbot?=
Guest
Posts: n/a
 
      10-24-2006
Beauregard T. Shagnasty wrote :
> Gérard Talbot wrote:
>
>> Beauregard T. Shagnasty wrote :
>>> So I change the UA string to "IE6.0 WinXP"

>> Do you know of a webpage that describes exactly (step by step) how to
>> modify the registry files to do this? I'm still searching...

>
> To change the UA string? With Firefox,


Oops, my mistake. I reversed what you wrote in my mind.

I meant to say that one can "regedit" MSIE 6 in a way to modify its
userAgent string. I know it's doable: I've heard people doing it. But I
don't know how to do this and wondered if you knew how (step by step).

E.g.:
The user agent string, instead of saying, returning

"Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)"

could instead return

"Stop using userAgent string detection and start using object/feature
support detection as explained at
http://www.mozilla.org/docs/web-deve...jectFeatDetect "

Gérard
--
remove blah to email me
 
Reply With Quote
 
=?ISO-8859-1?Q?G=E9rard_Talbot?=
Guest
Posts: n/a
 
      10-24-2006
Jukka K. Korpela wrote :
> Scripsit Gérard Talbot:
>
>> jaydev wrote :
>>> Hi,
>>>
>>> I am looking for code to detect and redirect to the corresponding
>>> browser download page if the clients uses old version, could anyone
>>> have a sample code for this?

>>
>> Hello jaydev,
>>
>> You have an interesting and worthy post in there. It's definitely a
>> good question.

>
> Well, it might be a good _question_. The correct _answer_, though, is
> that such efforts are a waste of everyone's time, and worse.
>


It all depends actually on what is the whole webpage context, situation
(purpose served for browser detection), not just how detection is done -
that is if it can be done reliably - but also *_how_* people are invited
to upgrade. A simple clickable-reactive <browse happy image> might be
good enough, you know.

> The page author would just upset and throw out some part of potential
> users. If he somehow managed to make someone update his browser, this
> would still distract from the site's own content.
>


Any link involving a download would do that too. E.g.:

<object classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
codebase=
"http://java.sun.com/products/plugin/autodl/jinstall-1_5_0-windows-i586.cab#Version=1,5,0,9"

codetype="application/java" standby="Loading of applet in progress..."
height="200" width="350"> (...)
will involve an auto-download of 16.2MB download for anyone not using
JRE 1.5.0_b9.

> Besides, the detection is bound to fail, and the redirects are bound to
> take users to wrong pages.


Of course, that's possible and it's the danger. That's why it will
always be best to create real link in a webpage where people can choose
a browser (download) by themselves and not via javascript, which as you
rightly point out, is not 100% full-proof.

> Maybe not immediately, but next month or next
> year. If you can make me believe that authors who write browser-sniffing
> and browser-redirection code will actually _maintain_ the monstrosity
> they create, you might just as well try making me believe in elves,
> Santa Claus, the Great Pumpkin, and even politicians' promises before
> elections.


Very often, they don't maintain the monstruosity they create ... or copy
from others' sites.

Jukka, just visit my own website http://www.gtalbot.org/ and you'll see
that all links at the bottom of the webpages can not mislead or
misredirect visitors.

I do use some kind of browser detection in a few of my DHTML section
webpages and it happened once, after a browser upgrade (involving
Opera), that it no longer worked, and so, I had to update the whole
thing, tune again.

If you include the following in a webpage

<!--[if gte IE 4]>
<p>You're using Internet Explorer which is known to be prone to
spywares, to have unpatched security weaknesses and to make computers
unsafe. For best security and better usability, please consider
switching to a better browser. You may visit <a
href="http://browsehappy.com/"><img
src="http://browsehappy.com/buttons/bh_185x75.gif" width="185"
height="75 alt="Browse Happy" style="vertical-align: bottom;"></a> for
explanations and assistance.</p>
<![endif]-->

it will work accordingly, as expected for IE users and it should still
work for many years.

Gérard
--
remove blah to email me
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
mobile browser detection and redirection Carlos ASP .Net 4 08-11-2009 08:28 AM
java version detection and browser notification G. Garrett Campbell Java 5 01-31-2008 10:26 AM
browser detection and redirection jaydev ASP .Net 1 10-23-2006 08:53 PM
browser detection and redirection jaydev ASP .Net Web Services 0 10-23-2006 08:31 PM
Detection of redirection, possible? Shannon Fang Ruby 2 10-27-2005 07:49 AM



Advertisments