NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Website Development
Reload this Page Browser Sniffer

Website Development Development concepts, scripts, sponsors and affiliate programs.

Advanced Search


Closed Thread
 
LinkBack Thread Tools
Old 08-07-2005, 10:36 AM THREAD STARTER               #1 (permalink)
New Member
Join Date: Aug 2005
Posts: 4
dog rout 21 is an unknown quantity at this point
 



Browser Sniffer


Hello Newbie here

I'm currently developing a new website. For this I have two different css files, one for IE and one for Firefox. I've been told that I can use a browser sniffer to load the correct css file depending upon the visitors browser type. Is this possible? if so does anyone know a good free browser sniffer script that will do this?

thanks
dog rout 21 is offline  
Old 08-07-2005, 11:34 AM   #2 (permalink)
NamePros Regular
 
unknownz's Avatar
Join Date: Aug 2005
Posts: 727
unknownz is just really niceunknownz is just really niceunknownz is just really niceunknownz is just really niceunknownz is just really niceunknownz is just really niceunknownz is just really niceunknownz is just really nice
 



Originally Posted by dog rout 21
Hello Newbie here

I'm currently developing a new website. For this I have two different css files, one for IE and one for Firefox. I've been told that I can use a browser sniffer to load the correct css file depending upon the visitors browser type. Is this possible? if so does anyone know a good free browser sniffer script that will do this?

thanks
hi
????: NamePros.com http://www.namepros.com/website-development/113416-browser-sniffer.html
check out the script available on the following link

http://www.php-mysql-perl.com/script...er_script.html

if you are not satisfied then search for other scripts on hotscripts.com
__________________
:laugh:...::::Pakisp.net::::...-The Entertainment Pack Pakisp.net :wave:
Free Web Directory
unknownz is offline  
Old 08-07-2005, 11:52 AM THREAD STARTER               #3 (permalink)
New Member
Join Date: Aug 2005
Posts: 4
dog rout 21 is an unknown quantity at this point
 



thats great cheers, my next problem is how would i call the css files using that script??

say the 2 css files were called ie.css and ff.css, ive inserted the script below

Code:
<script type="text/javascript">

//CS1.1

var exclude=1;
var agt=navigator.userAgent.toLowerCase();
var win=0;var mac=0;var lin=1;
if(agt.indexOf('win')!=-1){win=1;lin=0;}
if(agt.indexOf('mac')!=-1){mac=1;lin=0;}
var lnx=0;if(lin){lnx=1;}
var ice=0;
var ie=0;var ie4=0;var ie5=0;var ie6=0;var com=0;var dcm;
var op5=0;var op6=0;var op7=0;
var ns4=0;var ns6=0;var ns7=0;var mz7=0;var kde=0;var saf=0;
if(typeof navigator.vendor!="undefined" && navigator.vendor=="KDE"){
	var thisKDE=agt;
	var splitKDE=thisKDE.split("konqueror/");
	var aKDE=splitKDE[1].split("; ");
	var KDEn=parseFloat(aKDE[0]);
	if(KDEn>=2.2){
		kde=1;
		ns6=1;
		exclude=0;
		}
	}
else if(agt.indexOf('webtv')!=-1){exclude=1;}
else if(typeof window.opera!="undefined"){
	exclude=0;
	if(/opera[\/ ][5]/.test(agt)){op5=1;}
	if(/opera[\/ ][6]/.test(agt)){op6=1;}
	if(/opera[\/ ][7-9]/.test(agt)){op7=1;}
	}
else if(typeof document.all!="undefined"&&!kde){
	exclude=0;
	ie=1;
	if(typeof document.getElementById!="undefined"){
		ie5=1;
		if(agt.indexOf("msie 6")!=-1){
			ie6=1;
			dcm=document.compatMode;
			if(dcm!="BackCompat"){com=1;}
			}
		}
	else{ie4=1;}
	}
else if(typeof document.getElementById!="undefined"){
	exclude=0;
	if(agt.indexOf("netscape/6")!=-1||agt.indexOf("netscape6")!=-1){ns6=1;}
	else if(agt.indexOf("netscape/7")!=-1||agt.indexOf("netscape7")!=-1){ns6=1;ns7=1;}
	else if(agt.indexOf("gecko")!=-1){ns6=1;mz7=1;}
	if(agt.indexOf("safari")!=-1 || (typeof document.childNodes!="undefined" && typeof document.all=="undefined" && typeof navigator.taintEnabled=="undefined")){mz7=0;ns6=1;saf=1;}
	}
else if((agt.indexOf('mozilla')!=-1)&&(parseInt(navigator.appVersion)>=4)){
	exclude=0;
	ns4=1;
	if(typeof navigator.mimeTypes['*']=="undefined"){
		exclude=1;
		ns4=0;
		}
	}
if(agt.indexOf('escape')!=-1){exclude=1;ns4=0;}
if(typeof navigator.__ice_version!="undefined"){exclude=1;ie4=0;}

</script>
dog rout 21 is offline  
Old 08-07-2005, 12:15 PM   #4 (permalink)
NamePros Regular
 
unknownz's Avatar
Join Date: Aug 2005
Posts: 727
unknownz is just really niceunknownz is just really niceunknownz is just really niceunknownz is just really niceunknownz is just really niceunknownz is just really niceunknownz is just really niceunknownz is just really nice
 



to be honest i am not that good at programming but i think if you read the following it might be of some help to you

Code:
      var	 returns 	Description
      		
      ie	0 	Internet Explorer 4+ and IE-based third-party browsers. You can also be more specific:
      ie4	0 	... Internet Explorer 4 only.
      ie5	0 	... Internet Explorer 5 or 6.
      ie6	0 	... Internet Explorer 6 only.

       
      ns4	0 	Netscape 4

       
      ns6	1 	Gecko and KDE-based browsers - which includes Netscape 6 and 7, Mozilla, Konqueror and Safari. You can also identify smaller groups within this:
      ns7	0 	... Netscape 7.
      mz7	1 	... any gecko browser except Netscape. This is principally designed to identify Mozilla's own builds from Version 0.6 onwards, but it also returns true for any other non-netscape gecko browser.
      kde	0 	... Konqueror, from KDE 2.2 onwards.
      saf	0 	... Safari. This variable will identify Safari irrespective of which browser it's set to identify as.

       
      op5	0 	Opera 5
      op6	0 	Opera 6
      op7	0 	Opera 7

      These variables will identify Opera irrespective of which browser it's set to identify as.

Underpinning these is a safety variable, for protecting legacy browsers:

      	
      exclude	0 	

There are also three OS variables:

      		
      win	1 	Windows
      mac	0 	Mac OS
      lin	0 	Linux, or anything else

and you can query a lower-case version of the user agent string:

      	
      agt	mozilla/5.0 (windows; u; windows nt 5.1; en-gb; rv:1.7.8) gecko/20050511 firefox/1.0.4 	

The sniffer variables are global, and therefore available to any other scripts on the same page. They allow you to code for or exclude specific browsers, eg:

if (mac&&ie5) { ... internet explorer 5 on a mac ... }
if (!ns4) { ... not netscape 4 ... }
if (win&&(op5||op6)) { ... a windows version of opera 5 or 6 ... }
if (ie5||ns6||op7) { ... ie5+, gecko, kde or opera 7 ... }

Remember that some browsers return true for more than one variable:

    * Explorer 6 returns true for (ie6) and also for (ie)
    * Explorer 5 or 6 return true for (ie5) and also for (ie)
    * Explorer 4 returns true for (ie4) and also for (ie)
    * Konqueror returns true for (kde) and also for (ns6)
    * Safari returns true for (saf) and also for (ns6)
    * All Gecko-based browsers which aren't Netscape return true for (mz7) and also for (ns6) 

The exclude variable returns true for all unspecified browsers. This is very useful for protecting them from scary DHTML, eg:

if (!exclude) { ... modern browsers only ... }

You may find it necessary to use a combination of expressions to get to the browser you need, eg:

if (!exclude) {
    if (ns6||op7) { ... gecko, KTHML or Opera 7 ... }
    else if (ie5) { ... internet explorer 5+ ... }
    else { ... any other dhtml browser ... }
    }

There are several minor browsers which have enough DHTML support to pass one of the object tests, but not enough to be useful. The script specifically filters out (adds to the exclude group) - Espial Escape, ICEBrowser and OmniWeb.
__________________
:laugh:...::::Pakisp.net::::...-The Entertainment Pack Pakisp.net :wave:
Free Web Directory
unknownz is offline  
Old 08-07-2005, 10:37 PM   #5 (permalink)
NamePros Regular
 
Rowan W's Avatar
Join Date: Dec 2004
Location: QLD, Australia
Posts: 713
Rowan W will become famous soon enough
 



Firstly, don't do it.

Secondly, that's a lot of code.

Thirdly, http://www.quirksmode.org/css/condcom.html - http://www.dithered.com/css_filters/...mments_ie.html
Rowan W is offline  
Old 08-08-2005, 02:39 AM THREAD STARTER               #6 (permalink)
New Member
Join Date: Aug 2005
Posts: 4
dog rout 21 is an unknown quantity at this point
 



is there any way of doing that without embedding the css?? it just makes the coding too messy.

Anymore opinions/suggestions? all are welcome

just found this and its sorted my problem, thanks for everyones help

http://www.siteuri.ro/developer/css-...ifferences.php
dog rout 21 is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
msn.com? new browser??? LeeRyder The Break Room 7 04-22-2005 10:29 AM
2 Huge Name Forsale Vegas Entertainment Domains For Sale - Make Offer 9 09-21-2004 03:37 PM
Brand New Domain Name Resource! Whois, Browser ++ NameTower For Sale / Advertising Board 0 03-30-2004 03:45 PM
Get YourCompanyName Branded Browser for your customers uv3net For Sale / Advertising Board 0 01-22-2004 12:12 PM
Bad browser detector script? deadserious Web Design Discussion 10 02-19-2003 10:30 PM

Liquid Web Smart Servers  
All times are GMT -7. The time now is 03:05 AM.

Managed Web Hosting by Liquid Web
Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger