SitePoint Sponsor |
|
User Tag List
Results 1 to 4 of 4
Thread: browser detection
Hybrid View
-
Jul 25, 2006, 13:00 #1
- Join Date
- Apr 2005
- Posts
- 165
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
browser detection
I'm trying to writ a browser detection script and it seems to work but I was wondering if there is an easier way and/or if this was right.
Code:<!-- //let's see what browser we have first (firefox test) if (navigator.appName != "Netscape" || navigator.appVersion <= "5.0") { //let's see what IE browser they are running if(navigator.userAgent.indexOf("MSIE 6.0") < 6.0) { // show CSS header on page to display message and browser links window.alert("browser out of date!") //testing message; } } } -->
The line in question is
Code:if(navigator.userAgent.indexOf("MSIE 6.0") < 6.0) { -->
I'm working with a guy that has a client that still uses 5.2 on a mac, and they have several client using old browsers who say the page doesn't display properly. If that helps i any way.
I know there are several browser scripts out there but I am new to javascript and to copy and paste wouldn't help me understand the language so I decided to write my own instead so please excuse the neophyte question.
Thank you all in advance.
-
Jul 25, 2006, 13:10 #2
- Join Date
- Jul 2005
- Location
- West Springfield, Massachusetts
- Posts
- 17,290
- Mentioned
- 198 Post(s)
- Tagged
- 3 Thread(s)
conditional comments
Browser detection is not best practice. It's better to test for what is supported. But if you are only doing this to apply different CSS forr older browsers, I think using conditional comments is the way to go. AFAIK only IE recognises "conditional comments".
should bring up a lot of results, but you could start here. http://msdn.microsoft.com/workshop/a...omment_ovw.asp
Big Change Coming Soon - if you want your PMs save them now!
What you need to do to prepare for our migration to Discourse
A New SitePoint Forum Experience: Our Move to Discourse
-
Jul 25, 2006, 13:21 #3
- Join Date
- Apr 2005
- Posts
- 165
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I see your point that it should be done that way. In fact the site is not displaying properly mostly becasue of IE's incorrect box model. But since the project is already completed (and I should have checked IE 5 anyway I guess) I was looking for a less unobtrusive way to just make people aware that their browser was out of date. Rather than adding a bunch if IE specific comments to the page.
-
Jul 25, 2006, 16:15 #4
- Join Date
- Jul 2005
- Location
- West Springfield, Massachusetts
- Posts
- 17,290
- Mentioned
- 198 Post(s)
- Tagged
- 3 Thread(s)
upgrading
Maybe you and I both know they should upgrade, but they may not want or be able to. My brother has an old computer that is so low on memory that he can't upgrade unless he deletes the existing software first. Plus he's comfortable with what he knows and isn't so keen on the idea of "risking" an attempt to upgrade. He knows how to log on but not much more. It may be better to do a little extra work and not risk upsetting the "old fashioned" folks. Even if you tell them it's their fault if it doesn't look/behave right, a part of them will still think it's your fault for not doing it right. After all, other sites look OK.
Big Change Coming Soon - if you want your PMs save them now!
What you need to do to prepare for our migration to Discourse
A New SitePoint Forum Experience: Our Move to Discourse
Bookmarks