|
-
Reef Shark
How do you test what broswer a person is using on a web site?
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.
God damnit, better graphics != revolutionary gaming! Get it through your skull!
-
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
Crusader for the 64-bit Era.
New Rule: 2GB per core, minimum.
Intel i7-9700K | Asrock Z390 Phantom Gaming ITX | Samsung 970 Evo 2TB SSD
64GB DDR4-2666 Samsung | EVGA RTX 2070 Black edition
Fractal Arc Midi |Seasonic X650 PSU | Klipsch ProMedia 5.1 Ultra | Windows 10 Pro x64
-
Ursus Arctos Moderatis
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>
-
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
Crusader for the 64-bit Era.
New Rule: 2GB per core, minimum.
Intel i7-9700K | Asrock Z390 Phantom Gaming ITX | Samsung 970 Evo 2TB SSD
64GB DDR4-2666 Samsung | EVGA RTX 2070 Black edition
Fractal Arc Midi |Seasonic X650 PSU | Klipsch ProMedia 5.1 Ultra | Windows 10 Pro x64
-
Ursus Arctos Moderatis
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).]
-
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
Crusader for the 64-bit Era.
New Rule: 2GB per core, minimum.
Intel i7-9700K | Asrock Z390 Phantom Gaming ITX | Samsung 970 Evo 2TB SSD
64GB DDR4-2666 Samsung | EVGA RTX 2070 Black edition
Fractal Arc Midi |Seasonic X650 PSU | Klipsch ProMedia 5.1 Ultra | Windows 10 Pro x64
-
Hammerhead Shark
Quite a few scripts here. 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).]
-
Ursus Arctos Moderatis
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! 
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.
-
Reef Shark
Thanks for the help all, I'm sure I'll be able to rip all the code I need from there.
------------------
Kill em all and let God sort'em out.
WoU
Orc, 4.9k acres
God damnit, better graphics != revolutionary gaming! Get it through your skull!
-
Tiger Shark
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...
XP 1600+
MSI KT333
512 PC2700
AOpen Geforce4 4200
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|