Forum Moderators: open

Message Too Old, No Replies

Browser Sniffing

         

madcat

4:28 pm on Feb 5, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



What if any, are the technical drawbacks of using a browser sniffing program to present users with an alternate page when reaching a site? I'd imagine it's possible using ASP or PHP, so no JavaScript would have to be used. What are some of the other downsides to this approach?

BlobFisk

4:57 pm on Feb 5, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi madcat,

The first I can see is that you are increasing your workload by having to develop different pages for different browsers.

For browser sniffing I tend to stick to client side languages and have never done it in a server side language (is it possible? ASP/PHP/JSP gets run by the server before being shipped out to the client?).

madcat

5:19 pm on Feb 5, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



i guess what i was really thinking about is presenting certain browsers with a style sheet they can handle using php to sniff em out. though it would be great too if i could present them with a message to upgrade based on their browser.

[edited by: madcat at 5:44 pm (utc) on Feb. 5, 2003]

BlobFisk

5:36 pm on Feb 5, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I still think that the client side is the best way to go, especially for style sheets (unless, of course, you have a specific reason for avoiding a client side script).

You could also use IE conditionals, which tedster has explained here [webmasterworld.com]. Using both the link and @import css calls, allows you to cater for modern browsers and NN4.x, and some JavaScript sniffing can allow you to present a style sheet to each particular browser, as well as alerting them to upgrade if you want.

GaryK

5:38 pm on Feb 5, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



IF you're going to use PHP and browscap.ini to do the sniffing on the server-side be sure you're using PHP 4.3.0 or later. Earlier versions have some serious bugs in the get_browser() function; including one which causes PHP to crash horribly on startup. If you need an updated browscap.ini see the site in my profile.

madcat

5:45 pm on Feb 5, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



thanks for your replies, i'll be looking into all of these options.

madcat

9:56 pm on Feb 10, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



GaryK- Don't see a site in your profile.

Also, here is what I'd like to do. Basically, identify if a user is browsing with Internet Explorer Version 5, and if so, present them with a screen that has a link to an upgrade site, possibly a picture and a paragraph of text.

Since I'm only testing for one browser, it seems like I could forgo lengthy javascripts and just insert one or two lines of code plus my html. Is this possible?

//detect IE5.0
if (navigator.appVersion.indexOf("MSIE 5.0")!=-1)
alert("You're using IE5.5!")

>> Really don't know javascript, how would I need to present my html with this.

Thanks for any help.
M

HarryM

12:16 am on Feb 11, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



There is a free download phpSniff whuch I use.

If you are using php, you can call this in the head section of your page, and then use an if statement to write an alternative page for IE5 browsers, or the originally intended page for anything else.

If you use Javascript you will miss anybody who has it turned off.

[edit]On thinking about it, I can't imagine anything that is going to annoy a user more than being diverted to a page which is really nothing more than an advert telling them their equipment is crap! :)[/edit]

DrDoc

12:45 am on Feb 11, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Well, if you're just checking for IE, why not do this:

<!--[if IE5]>
Code that will be visible in IE 5 goes here. It will be hidden to all other browsers.
<![endif]-->

gmiller

2:29 am on Feb 11, 2003 (gmt 0)

10+ Year Member



Downsides of browser-sniffing? The big one is that, sooner or later, a browser developer does something you didn't plan for. For example, see all the recent headlines about MSN's sniffing and Opera 7.

DrDoc

9:43 pm on Feb 11, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



gmiller, I ahve to say that MSN's way of "sniffing" is surely not what madcat is talking about.

It's one thing to use browser sniffing to improve the visitor's experience depending on the browser they use .. and another thing to mess things up or exclude visitors just because they use a certain browser.

For example .. I could care less about NN4 browsers .. But, I still make sure they will be able to use my sites. Sure, the layout it far from what it's intended to be .. But it's not messed up.

madcat, I don't think there are any downsides to browser sniffing - as long as you do it in a smart way. Also, if you only do it when it's a necessity, I can't see why it should cause any problems.

Just make sure that the default content is viewable by all browsers.

Use browser sniffing to add content, not remove :)