Click to See Complete Forum and Search --> : How do you test what broswer a person is using on a web site?


Pestilence
01-11-2001, 08:25 PM
I'm the webmaster for a student organization and I want to be able to test what broswer a person uses and then what version it is so that I could then make a direction page that says whether or not their version is too old to be properly viewed with my web site.

------------------
Kill em all and let God sort'em out.

James
01-11-2001, 09:38 PM
Check out the source code in the following page. It does a browser test.

http://home.netscape.com/download/index.html?cp=djuc1

------------------
"I'd kill for you, Marge. Please ask me to kill for you." -Homer Simpson

Grizzly
01-11-2001, 10:21 PM
This won't test version, but this simple dimple piece of JavaScript will determine if it's IE, or Netscape:

<script language="JavaScript">
if (navigator.appName == "Microsoft Internet Explorer")
{
location.href = "index2.html";
}
else
{
location.href = "index3.html";
}
</script>

James
01-11-2001, 10:27 PM
In that case, would this be a browser/version script? This is taken(cut/pasted) from the site I linked to earlier.

<SCRIPT LANGUAGE="javascript">
<!--
window.name='MainFrame';

function open_content_win(win) {
browser_name = navigator.appName;
browser_version = parseFloat(navigator.appVersion);
str= win;

if (browser_name == "Microsoft Internet Explorer" && browser_version < 5.0) {
searchWin = window.open(str,'searchWin','resizable=no,scrollbars=yes,wid th=620,height=480,status=no,location=no,toolbar=no,menubar=n o');

window.open(str,'searchWin','resizable=no,scrollbars=yes,wid th=620,height=480,status=no,location=no,toolbar=no,menubar=n o');
}
else if (browser_name == "Netscape" && browser_version <= 4.01) {
searchWin = window.open(str,'searchWin','resizable=no,scrollbars=yes,wid th=620,height=540,status=no,location=no,toolbar=no,menubar=n o');

window.open(str,'searchWin','resizable=no,scrollbars=yes,wid th=520,height=540,status=no,location=no,toolbar=no,menubar=n o');

if (browser_version >= 3.0) {
searchWin.focus();
}
searchWin.refer = self;
}
else {
searchWin = window.open(str,'searchWin','resizable=no,scrollbars=yes,wid th=640,height=520,status=no,location=no,toolbar=no,menubar=n o');

window.open(str,'searchWin','resizable=no,scrollbars=yes,wid th=640,height=520,status=no,location=no,toolbar=no,menubar=n o');

searchWin.focus();
searchWin.refer = self;
}
}

//-->
</SCRIPT>

------------------
"I'd kill for you, Marge. Please ask me to kill for you." -Homer Simpson

Grizzly
01-11-2001, 11:40 PM
Aye, that's a bloated script that is doing stuff you don't need though. Just plug in those "navigator.appVersion" paremeters in your 'if' statements, and adjust accordingly.

Example:

<script language="JavaScript">
if (navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion >= 5.0)
{
location.href = "index2.html";
}
elseif (navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion < 5.0)
{
location.href = "index3.html";
}
else
{
location.href = "index4.html";
}
</script>

[This message has been edited by Grizzly (edited January 11, 2001).]

James
01-12-2001, 01:08 AM
Sorry, Griz. I had used the Rip out and paste method straight from the source code on Netscape's site. It was definitely bloated, but not knowing Java myself, I did not know how to par it down.

------------------
"I'd kill for you, Marge. Please ask me to kill for you." -Homer Simpson

slipgun
01-12-2001, 01:33 AM
Quite a few scripts here. (http://javascript.internet.com) Aren't Java and JavaScript different languages?

------------------
I, Bin Laden, declare a day of mourning in the whole of the Middle East over the death of an atomic bomb buried in the seabed of the Pacific

[This message has been edited by slipgun (edited January 12, 2001).]

Grizzly
01-12-2001, 02:54 AM
Originally posted by James:
Sorry, Griz. I had used the Rip out and paste method straight from the source code on Netscape's site. It was definitely bloated, but not knowing Java myself, I did not know how to par it down.




Hey whatever floats your boat James! http://www.sharkyforums.com/ubb/tongue.gif

And yeah Slippy, JavaScript and Java are two different things entirely. JavaScript is a web scripting language, and Java is a full blown Object Oriented Programming Language.

Pestilence
01-12-2001, 12:30 PM
Thanks for the help all, I'm sure I'll be able to rip all the code I need from there. http://www.sharkyforums.com/ubb/smile.gif

------------------
Kill em all and let God sort'em out.

WoU
Orc, 4.9k acres

GrayCalx
01-12-2001, 06:10 PM
Originally posted by slipgun:
Quite a few scripts here. (http://javascript.internet.com) Aren't Java and JavaScript different languages?




Yeah they are. Java is more of a C++ type of language, whereas javascipt is pretty much strictly used in web pages, and is client-sided (its loaded onto the clients computer as the page downloads and runs from there). For anyone who cares...