dantheriver
asked on
Determine OS and Browser from HTTP_User_Agent
We are currently using BrowserHawk to determine the environment of users of our web application. The only data that I really need to collect is the users OS and Browser. Browser Hawk is overkill for what we need, and rather than renewing our Expensive subscription with them, I am looking for a reliable way to just parse the OS and browser out of the HTTP_USER_AGENT. Does anyone know of a good way to do this or any alternative componenets to browserhawk?
I use code like this to see what is really available:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title> New Document </title>
</head>
<body>
<%
For each objItem in Request. ServerVariables
Response.write(objItem & ": " & Request.ServerVariables(ob jItem) & "<br>")
Next
%>
</body>
</html>
FtB
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title> New Document </title>
</head>
<body>
<%
For each objItem in Request. ServerVariables
Response.write(objItem & ": " & Request.ServerVariables(ob
Next
%>
</body>
</html>
FtB
Finally, if you keep your browscap.ini file up to date, you can use that to get all of the information easily and reliably:
http://www.abiglime.com/webmaster/articles/asp/121798.htm
FtB
http://www.abiglime.com/webmaster/articles/asp/121798.htm
FtB
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hai,
Also add these to your page
Function GetIEVersion(strData)
dim x, y
GetIEVersion=0
x=instr(1, strData,"MSIE")+4
y=instr(x,strData,";")
if x>0 and Y>0 and Y>x then
GetIEVersion=mid(strData,x ,y-x)
end if
end function
Bye
Ajai
Also add these to your page
Function GetIEVersion(strData)
dim x, y
GetIEVersion=0
x=instr(1, strData,"MSIE")+4
y=instr(x,strData,";")
if x>0 and Y>0 and Y>x then
GetIEVersion=mid(strData,x
end if
end function
Bye
Ajai
>or any alternative componenets to browserhawk?
http://www.rodsdot.com/ee/browser_test.asp
Was put together from various EE questions from users requesting how to test browser capabilities. It is overkill for your question, but might save you from an expensive renewal. It isn't nearly as capable as BrowserHawk, but it does demo how to test for many common browser capabilities.
http://www.rodsdot.com/ee/browser_test.asp
Was put together from various EE questions from users requesting how to test browser capabilities. It is overkill for your question, but might save you from an expensive renewal. It isn't nearly as capable as BrowserHawk, but it does demo how to test for many common browser capabilities.
Might beef it up with Ajai's code if Ajai doesn't mind.
rdivilbiss,
Where can you download the code for (http://www.rodsdot.com/ee/browser_test.asp). Or do you just use the javascript on that page? I didn't see any code that makes the alert box come up when you load the page so I assume there was something else behind it.
Where can you download the code for (http://www.rodsdot.com/ee/browser_test.asp). Or do you just use the javascript on that page? I didn't see any code that makes the alert box come up when you load the page so I assume there was something else behind it.
The code is in the box with the yellow background. Look closely...it isn't all JavaScript. Most of it is, but not all.
There is a cookies.js file and a java applet.
The cookies.js file can be found at:
Published on: Saturday 21st February 1998 By: Martin Webb
tech.irt.org/articles/js06 4
www.deletemycookies.com/intelligentcookies.htm
The java applet can be had here:
Published by Michael Horowitz
http://javatester.org/version.html
http://www.michaelhorowitz.com/javatester.results.html
I don't distribute those, but only point you to the copyright holders page, where you may obtain them in accordance with their respective copyright requirements.
Regards,
Rod
There is a cookies.js file and a java applet.
The cookies.js file can be found at:
Published on: Saturday 21st February 1998 By: Martin Webb
tech.irt.org/articles/js06
www.deletemycookies.com/intelligentcookies.htm
The java applet can be had here:
Published by Michael Horowitz
http://javatester.org/version.html
http://www.michaelhorowitz.com/javatester.results.html
I don't distribute those, but only point you to the copyright holders page, where you may obtain them in accordance with their respective copyright requirements.
Regards,
Rod
Just in case something is missing from the code box:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Browser Test</title>
<meta name="author" content="Roderick Divilbiss">
<meta name="copyright" content="© 2005 Roderick Divilbiss">
<!-- Intelligent Cookies -->
<!-- Published on: Saturday 21st February 1998 By: Martin Webb -->
<!-- tech.irt.org/articles/js06 4 -->
<!-- www.deletemycookies.com/intelligentcookies.htm -->
<script language="javascript" type="text/javascript" src="../include/cookies.js "></script >
<script language="javascript" type="text/javascript">
<!--
document.writeln('<pre><st rong>JavaS cript is enabled</strong></pre>');
storeMasterCookie();
storeIntelligentCookie("TE ST","Cooki e Accepted");
if (Get_Cookie("TEST")!=null) {
document.writeln('<pre><st rong>'+Get _Cookie("T EST")+'</s trong></pr e>');
} else {
document.writeln('<pre><st rong>COOKI E REFUSED</strong></pre>');
}
if (navigator.javaEnabled()== true) {
document.writeln('<pre><st rong>Java Enabled</strong></pre>');
document.writeln('<div id="javaver">Testing....</ div>');
}else{
document.writeln('<pre><st rong>No Java</strong></pre>');
}
var myVal = 5;
function pSuccess() {
if (myVal==0) {
document.getElementById('p opres').in nerHTML = '<pre><strong>POPUP WORKED</strong></pre>';
return true;
} else {
document.getElementById('p opres').in nerHTML = '<pre><strong>POPUP BLOCKED</strong></pre>';
return false;
}
}
var popup = window.open('testpop.asp', 'test');
if (popup.opener == null) popup.opener = self;
setTimeout('pSuccess()',10 00);
function flashInstalled()
{
result = false;
if (navigator.mimeTypes && navigator.mimeTypes["appli cation/x-s hockwave-f lash"])
{
result = navigator.mimeTypes["appli cation/x-s hockwave-f lash"].ena bledPlugin ;
}
else if (document.all && (navigator.appVersion.inde xOf("Mac") ==-1))
{
// IE Windows only -- check for ActiveX control, have to hide code in eval from Netscape (doesn't like try)
eval ('try {var xObj = new ActiveXObject("ShockwaveFl ash.Shockw aveFlash") ;if (xObj) result = true; xObj = null; } catch (e) {}');
}
return result;
}
if (flashInstalled()) {
document.writeln('<pre><st rong>Flash : </strong>Installed</pre>') ;
} else {
document.writeln('<pre><st rong>Flash : </strong>Missing</pre>');
}
document.writeln('<pre><st rong>Scree n Size: </strong> '+screen.width+'X'+screen. height+'</ pre>');
document.writeln('<pre><st rong>Color Depth: </strong> '+screen.colorDepth+' bit</pre>');
document.writeln('<pre><st rong>Avail able Window: </strong> '+screen.availHeight+'X'+s creen.avai lWidth+'</ pre>');
//-->
</script>
<noscript>
<pre><strong>JavaScript is disabled.</strong></pre>
</noscript>
<title>Browser Test</title>
<style>
<!--
#code {
border: 1px solid #000000;
padding-left:10px;
padding-right:10px;
padding-top:10px; background-color:#FFFFCC
}
-->
</style>
</head>
<body>
<!-- Published by Michael Horowitz -->
<!-- http://javatester.org/version.html -->
<!-- http://www.michaelhorowitz.com/javatester.results.html -->
<APPLET codeBase="." height="0" width="0"
code="JavaVersionDisplayAp plet.class "
name="display"
mayscript VIEWASTEXT>
</APPLET>
<div id="popres">Testing....</d iv>
<script type="text/vbscript" language="vbscript">
on error resume next
msgbox("VBScript is enabled")
</script>
<noscript>
<pre><strong>VB Script is disabled.</strong></pre><b r>
</noscript>
<%
response.write("<pre>")
for each item in request.servervariables
response.write "<strong>" & item & ": <strong>" & request.servervariables(it em) & "<br>"
next
%>
<script>
var app = document.applets[0];
var version = app.getVersion();
var vendor = app.getVendor();
if (version!=null) {
document.getElementById('j avaver').i nnerHTML = '<pre><strong>Version: </strong>'+vendor+' '+version+'</pre>';
} else {
document.getElementById('j avaver').i nnerHTML = '<pre><strong>Version: </strong>Unable To Detect</pre>';
}
var i_activex;
</script>
<script type="text/vbscript">
on error resume next
i_activex = IsObject(CreateObject("Mic rosoft.Act iveXPlugin .1"))
</script>
<div id="code"><pre>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">;<br><html><br ><head& gt;<br>< ;title> Browser Test</title><br>< meta name="author" content="Roderick Divilbiss"><br>< ;meta name="copyright" content="© 2005 Roderick Divilbiss"><br>
<script language="javascript& quot; type="text/javascript " src="../include/cooki es.js" ;></ script> <br><sc ript language="javascript& quot; type="text/javascript "> <br><!- -<br>docum ent.writel n('<pre ><st rong>Ja vaScript is enabled</strong>< /pre>') ;<br>
storeMasterCookie();<br>st oreIntelli gentCookie ("TES T",&q uot;Cookie Accepted");<br>if (Get_Cookie("TEST&quo t;)!=null) {<br> document.writeln('<pre& gt;<str ong>'+G et_Cookie( "TEST ")+'& lt;/strong ></p re>');< br>} else {<br> document.writeln('<pre& gt;<str ong>COO KIE REFUSED</strong>< /pre>') ;<br>
}<br>
if (navigator.javaEnabled()== true) {<br> document.writeln('<pre& gt;<str ong>Jav a Enabled</strong>< /pre>') ;<br> document.writeln('<div id="javaver"> Testing... .</div& gt;'); <br>
}else{<br> document.writeln('<pre& gt;<str ong>No Java</strong></pr e>');<b r>
}<br>
var myVal = 5;<br>
function pSuccess() {<br> if (myVal==0) {<br> document.getElementById('p opres').in nerHTML = '<pre><strong> POPUP WORKED</strong></ pre>';< br> return true;<br> } else {<br> document.getElementById('p opres').in nerHTML = '<pre><strong> POPUP BLOCKED</strong>< /pre>'; <br> return false;<br> }<br>
}<br>
var popup = window.open('testpop.asp', 'test');<b r>if (popup.opener == null) popup.opener = self;<br>setTimeout('pSucc ess()',100 0);<br>
function flashInstalled() {<br> result = false;<br> if (navigator.mimeTypes && navigator.mimeTypes[" applicatio n/x-shockw ave-flash& quot;]){<b r> result = navigator.mimeTypes[" applicatio n/x-shockw ave-flash& quot;].ena bledPlugin ;<br> }<br> else if (document.all && (navigator.appVersion.inde xOf(" Mac") ==-1)) {<br> // IE Windows only -- check for ActiveX control, have to hide code in eval from Netscape (doesn't like try)<br> eval ('try {var xObj = new ActiveXObject("Shockw aveFlash.S hockwaveFl ash") ;if (xObj) result = true; xObj = null; } catch (e) {}');<br> }<br> return result;<br>
}<br>
if (flashInstalled()) {<br> document.writeln('<pre& gt;<str ong>Fla sh: </strong>Installed&l t;/pre> ');<br>} else {<br> document.writeln('<pre& gt;<str ong>Fla sh: </strong>Missing< /pre>') ;<br>
}<br>
document.writeln('<pre& gt;<str ong>Scr een Size: </strong> '+screen.width+'X'+screen. height+'&l t;/pre> ');<br>doc ument.writ eln('<p re>< strong> Color Depth: </strong> '+screen.colorDepth+' bit</pre>');<br>docu ment.write ln('<pr e><s trong>A vailable Window: </strong> '+screen.availHeight+'X'+s creen.avai lWidth+'&l t;/pre> ');<br><br >
//--><br>
</script><br><nos cript>< br> <pre><strong>J avaScript is disabled.</strong>&l t;/pre> <br></n oscript> ;<br><br>& lt;/head&g t;<br>< body><b r><APPL ET codeBase="." height="0" width="0" <br>code="JavaVersion DisplayApp let.class& quot; <br>name="display&quo t; <br>mayscript VIEWASTEXT><br></APP LET><br >
<div id="popres">T esting.... </div&g t;<br>< script type="text/vbscript&q uot; language="vbscript&qu ot;><br > on error resume next<br> msgbox("VBScript is enabled")<br></scr ipt><br > </p re>
<pre>
<%<br>response.write(&q uot;<pr e>" ;)<br>for each item in request.servervariables<br > response.write "<strong>" & item & ": <strong>" & request.servervariables(it em) & "<br>"<br>
next<br>%><br>
<script><br>var app = document.applets[0];<br>va r version = app.getVersion();<br>var vendor = app.getVendor();<br>if (version!=null) {<br> document.getElementById('j avaver').i nnerHTML = '<pre><strong> Version: </strong>'+vendor+' '+version+'</pre>';< br>} else {<br> document.getElementById('j avaver').i nnerHTML = '<pre><strong> Version: </strong>Unable To Detect</pre>';<br>
}<br>
var i_activex;
</script><br>
<script type="text/vbscript&q uot;><b r> on error resume next<br> i_activex = IsObject(CreateObject(&quo t;Microsof t.ActiveXP lugin.1&qu ot;))<br>& lt;/script ></pre>
<pre>
</body>
</html>
</pre></div>
</body>
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Browser Test</title>
<meta name="author" content="Roderick Divilbiss">
<meta name="copyright" content="© 2005 Roderick Divilbiss">
<!-- Intelligent Cookies -->
<!-- Published on: Saturday 21st February 1998 By: Martin Webb -->
<!-- tech.irt.org/articles/js06
<!-- www.deletemycookies.com/intelligentcookies.htm -->
<script language="javascript" type="text/javascript" src="../include/cookies.js
<script language="javascript" type="text/javascript">
<!--
document.writeln('<pre><st
storeMasterCookie();
storeIntelligentCookie("TE
if (Get_Cookie("TEST")!=null)
document.writeln('<pre><st
} else {
document.writeln('<pre><st
}
if (navigator.javaEnabled()==
document.writeln('<pre><st
document.writeln('<div id="javaver">Testing....</
}else{
document.writeln('<pre><st
}
var myVal = 5;
function pSuccess() {
if (myVal==0) {
document.getElementById('p
return true;
} else {
document.getElementById('p
return false;
}
}
var popup = window.open('testpop.asp',
if (popup.opener == null) popup.opener = self;
setTimeout('pSuccess()',10
function flashInstalled()
{
result = false;
if (navigator.mimeTypes && navigator.mimeTypes["appli
{
result = navigator.mimeTypes["appli
}
else if (document.all && (navigator.appVersion.inde
{
// IE Windows only -- check for ActiveX control, have to hide code in eval from Netscape (doesn't like try)
eval ('try {var xObj = new ActiveXObject("ShockwaveFl
}
return result;
}
if (flashInstalled()) {
document.writeln('<pre><st
} else {
document.writeln('<pre><st
}
document.writeln('<pre><st
document.writeln('<pre><st
document.writeln('<pre><st
//-->
</script>
<noscript>
<pre><strong>JavaScript is disabled.</strong></pre>
</noscript>
<title>Browser Test</title>
<style>
<!--
#code {
border: 1px solid #000000;
padding-left:10px;
padding-right:10px;
padding-top:10px; background-color:#FFFFCC
}
-->
</style>
</head>
<body>
<!-- Published by Michael Horowitz -->
<!-- http://javatester.org/version.html -->
<!-- http://www.michaelhorowitz.com/javatester.results.html -->
<APPLET codeBase="." height="0" width="0"
code="JavaVersionDisplayAp
name="display"
mayscript VIEWASTEXT>
</APPLET>
<div id="popres">Testing....</d
<script type="text/vbscript" language="vbscript">
on error resume next
msgbox("VBScript is enabled")
</script>
<noscript>
<pre><strong>VB Script is disabled.</strong></pre><b
</noscript>
<%
response.write("<pre>")
for each item in request.servervariables
response.write "<strong>" & item & ": <strong>" & request.servervariables(it
next
%>
<script>
var app = document.applets[0];
var version = app.getVersion();
var vendor = app.getVendor();
if (version!=null) {
document.getElementById('j
} else {
document.getElementById('j
}
var i_activex;
</script>
<script type="text/vbscript">
on error resume next
i_activex = IsObject(CreateObject("Mic
</script>
<div id="code"><pre>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">;<br><html><br
<script language="javascript&
storeMasterCookie();<br>st
}<br>
if (navigator.javaEnabled()==
}else{<br> document.writeln('<pre&
}<br>
var myVal = 5;<br>
function pSuccess() {<br> if (myVal==0) {<br> document.getElementById('p
}<br>
var popup = window.open('testpop.asp',
function flashInstalled() {<br> result = false;<br> if (navigator.mimeTypes && navigator.mimeTypes["
}<br>
if (flashInstalled()) {<br> document.writeln('<pre&
}<br>
document.writeln('<pre&
//--><br>
</script><br><nos
<div id="popres">T
<pre>
<%<br>response.write(&q
next<br>%><br>
<script><br>var app = document.applets[0];<br>va
}<br>
var i_activex;
</script><br>
<script type="text/vbscript&q
<pre>
</body>
</html>
</pre></div>
</body>
</html>
Hai rdivilbiss,
You can add those if you need... No probs about that... If possible just add a little bit of credit to my name :)
Bye
Ajai
You can add those if you need... No probs about that... If possible just add a little bit of credit to my name :)
Bye
Ajai
Ajai,
Of course. Note my care regarding the two libraries I did not write.
jrram,
Correction on the Applet link:
http://support.softartisans.com/kbview_839.aspx (zip file at the bottom of the page.)
Regards,
Rod
BTW: Anybody has a browser test I don't please let me know.
Of course. Note my care regarding the two libraries I did not write.
jrram,
Correction on the Applet link:
http://support.softartisans.com/kbview_839.aspx (zip file at the bottom of the page.)
Regards,
Rod
BTW: Anybody has a browser test I don't please let me know.
Rod,
Thanks :)
Bye
Ajai
Thanks :)
Bye
Ajai
https://www.experts-exchange.com/questions/10470618/ASP-call-to-get-current-browser-being-used.html?query=detect+browser+OS&topics=97
https://www.experts-exchange.com/questions/20467014/Check-the-OS.html?query=detect+browser+OS&topics=97
FtB