Click to See Complete Forum and Search --> : browser identification and redirection script
sciguyryan
08-15-2003, 05:52 AM
hi all,
could anyone provide a script thet identifies the users browser(+ version) and redirects them to a page accordingly.
if you could provide a script i would be most greatfull.
thank you in advance.
Khalid Ali
08-15-2003, 08:42 AM
search the forums for the answer and/or google.
Jupac
08-15-2003, 10:05 PM
Did u want some thing like this????
<SCRIPT LANGUAGE="JavaScript">
if (navigator.userAgent.indexOf("Opera")!= -1)
{ window.location.replace("http://www.you.com/blah.php");}
else if (navigator.userAgent.indexOf("MSIE")!= -1){ window.location.replace("http://www.u..com/index.html");}
else{ window.location.replace("http://www.u.com/sonthingelse.html");}</script>
to c wat broeswe they have
navigator.appName;
to c wat version
navigator.appVersion;
:"}
sciguyryan
08-16-2003, 04:38 AM
hi again:D,
that is what i wanted, i wanted a script that could redirect a browser by identifying it's version and thus it's compatability with different script languages and redirect them based on which languages they support to pages that exclude the languages they can't support such as... MSIE 1 & 2 dont support JavaScript or CSS and, i would like them to be sent to a page accordingly.
I've found this scripthat ID's the browser but, not the version and, it does not re-direct could you help with that?
here's the script:
<HTML>
<HEAD><TITLE> JavaScript 10 </TITLE>
<SCRIPT LANGUAGE="JavaScript">
<!--
// Michael P. Scholtis (mpscho@planetx.bloomu.edu)
function browsertest ()
{document.write("Congratulations, your browser has passed the JavaScript test!!!")}
// -- -->
</SCRIPT>
</HEAD>
<BODY>
<SCRIPT LANGUAGE="JavaScript">
<!-- Original:Gregor (legreg@legreg.de)-->
<!-- 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>
</BODY>
</HTML>
thank you for your help, any more help would be greatfully recived.
thank you in advance.
Jupac
08-16-2003, 04:09 PM
UMM
for if the have javascript enable
<noscript><META http-equiv="refresh" content="1; url=http://www.you.com/sorry.php"></noscript>
or
this to let ur usere c wat they have
<script>
var a = navigator.appName;
var b = navigator.appVersion;
var d = navigator.platform;
if (navigator.javaEnabled() < 1) e="No Java";
if (navigator.javaEnabled() == 1) e="Java";
if (d == "Win32"){d="Windows";}
</script>
<script>
document.write("Hi you are using "+a+""+b+"with "+e+" enabled on a "+d+" OS")
</script>
for the other script i got to get back to u on that 1
try this (http://www.webreference.com/tools/browser/javascript.html) browser sniffer.
if(is_ie6) { window.location.href="MyIE6page.html"; }
Search the web and try to write some code yourself.
You might be better off to just not use proprietary coding, though...
sciguyryan
08-17-2003, 05:03 AM
hi,
how do you use the code off the website specified by fang Or here:
http://www.mozilla.org/docs/webdeveloper/sniffer/browser_type.html
where would i put the code and, how would i use it?
I showed you how to use it!
sciguyryan
08-17-2003, 05:59 AM
hi,
sorry i didnt see that bit. thanks for the info though......