vedr: browser detection
følgende scripts kan bruges
<!-- ONE STEP TO INSTALL BROWSER & VERSION REDIRECT:
1. Add the last code into the BODY of your HTML document -->
<!-- STEP ONE: Copy this code into the BODY of your HTML document -->
<BODY>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
var name = navigator.appName;
var vers = navigator.appVersion;
vers = vers.substring(0,1); // or 0,4 could return 4.5 instead of just 4
if (name == "Microsoft Internet Explorer")
url="msie";
else
url="netscape";
url += vers + ".html";
document.write('<center>');
document.write('<A HREF="' + url + '">Enter</A>');
document.write('</center>');
// You may make the redirection automatic by using this
// window.location=url;
// instead of the three document.write lines above
// End -->
</script>
<!-- Script Size: 1.08 KB -->
It's often necessary to make a script only accessible to the newer
browsers (that can support the script without error) and keep older
browsers from trying to work with it. This script, as an added plus, is
very short
<!-- TWO STEPS TO INSTALL NEW BROWSERS ONLY:
1. Paste the coding into the HEAD of your HTML document
2. Add the last code into the BODY of your HTML document -->
<!-- STEP ONE: Copy this code into the HEAD of your HTML document -->
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function onlyNewbrowsers() {
browser = (((navigator.appName == "Netscape") &&
(parseInt(navigator.appVersion) >= 3 )) ||
((navigator.appName == "Microsoft Internet Explorer") &&
(parseInt(navigator.appVersion) >= 4 )))
if (browser) {
alert('You are obviously using Netscape 3+ or MSIE 4+. Older browsers are not allowed to read this.....')}
else {}
}
// End -->
</SCRIPT>
<!-- STEP TWO: Put this code into the BODY of your HTML document -->
<BODY>
<CENTER>
<FORM ACTION="" onSubmit="onlyNewbrowsers()">
<input type="submit" Value="New Browsers Only Script">
</FORM>
</CENTER>
<p><center>
<font face="arial, helvetica" size="-2">Free JavaScripts provided<br>
by <a href="
http://javascriptsource.com">The JavaScript Source</a></font>
</center><p>
<!-- Script Size: 1.04 KB -->
This script will also provide a little bit more information about the
visitor's browser
<!-- ONE STEP TO INSTALL BROWSER VERSION:
1. Paste the coding into the BODY of your HTML document -->
<!-- STEP ONE: Copy this code into the BODY of your HTML document -->
<BODY>
<CENTER>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
document.write("<B>"+navigator.appVersion+"</B><P>");
// End -->
</SCRIPT>
</CENTER>
<p><center>
<font face="arial, helvetica" size="-2">Free JavaScripts provided<br>
by <a href="
http://javascriptsource.com">The JavaScript Source</a></font>
</center><p>
<!-- Script Size: 0.50 KB -->
Unlike the previous browser information scripts, this one supports
Netscape 6 and Opera browsers!
<!-- ONE STEP TO INSTALL BROWSER VERSION:
1. Copy the coding into the BODY of your HTML document -->
<!-- STEP ONE: Paste this code into the BODY of your HTML document -->
<BODY>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
var useragent = navigator.userAgent;
var bName = (useragent.indexOf('Opera') > -1) ? 'Opera' : navigator.appName;
var pos = useragent.indexOf('MSIE');
if (pos > -1) {
bVer = useragent.substring(pos + 5);
var pos = bVer.indexOf(';');
var bVer = bVer.substring(0,pos);
}
var pos = useragent.indexOf('Opera');
if (pos > -1) {
bVer = useragent.substring(pos + 6);
var pos = bVer.indexOf(' ');
var bVer = bVer.substring(0, pos);
}
if (bName == "Netscape") {
var bVer = useragent.substring(8);
var pos = bVer.indexOf(' ');
var bVer = bVer.substring(0, pos);
}
if (bName == "Netscape" && parseInt(navigator.appVersion) >= 5) {
var pos = useragent.lastIndexOf('/');
var bVer = useragent.substring(pos + 1);
}
document.writeln('<b>Browser Name: </b>' + bName + '<br>');
document.writeln('<b>Browser Version: </b>' + bVer + '<br>');
// End -->
</script>
<p><center>
<font face="arial, helvetica" size"-2">Free JavaScripts provided<br>
by <a href="
http://javascriptsource.com">The JavaScript Source</a></font>
</center><p>
<!-- Script Size: 1.39 KB -->