Browser Detect & Redirect
I've looked around for one of these but none of them seem to do support Opera.
What I need is a PHP Script that will detect the browser and send it to a particular page based on that but it needs to support IE, NS & Opera.
Suzanne posted this at 05:12 — 16th February 2003.
She has: 5,507 posts
Joined: Feb 2000
What you *really* need to do is re-evaluate whether you really need to redirect to various browsers.
Khanny posted this at 05:13 — 16th February 2003.
They have: 51 posts
Joined: Dec 2002
yup definitely do, got a menu that doesn't work in Opera
Khanny posted this at 05:20 — 16th February 2003.
They have: 51 posts
Joined: Dec 2002
hmm wait never mind it seems to work in Opera now.
Busy posted this at 07:19 — 16th February 2003.
He has: 6,151 posts
Joined: May 2001
just make sure Opera isnt set as IE (f12 at bottom - set as opera)
Khanny posted this at 09:55 — 16th February 2003.
They have: 51 posts
Joined: Dec 2002
it was, cheers
dk01 posted this at 15:05 — 16th February 2003.
He has: 516 posts
Joined: Mar 2002
If you want one still then here is one:
http://www.conxiondesigns.com/source/?/cfg/apps/sniffer.php
-dk
mojojojo posted this at 20:24 — 18th February 2003.
They have: 15 posts
Joined: Feb 2003
I don't get it. Where in that code do we imput the redirect url's?
dk01 posted this at 23:24 — 19th February 2003.
He has: 516 posts
Joined: Mar 2002
Sorry. All you do is copy paste that code into your php document. Then use if/else statements to redirect the url:
<?php
if($browser==\"msie\") {
$url = \"ie_page.php\"; // Internet explorer
{ elseif($browser==\"ns\") {
$url = \"ns_page.php\"; // Netscape
} else {
$url = \"other_page.php\"; // Everything else
}
header('Location:' . $url);
?>
You can also check it by using the (integer) variable called $version to redirect using the version or use $os to redirect according to the operating system.
P.S. This way is not fooled by Opera browser spoofing so if you want to detect opera simply use $browser == "opera"
-dk
fifeclub posted this at 18:10 — 25th February 2003.
He has: 688 posts
Joined: Feb 2001
I'm so excited to actually be able to answer a question! I'm always the one asking questions around here and it feels nice to be able to help somebody else. Anyway, here's the script I use to do exactly what you're asking for (even though it seems you may not need it anymore).
<?php
//DETECT BROWSER
{ global $HTTP_USER_AGENT;
if(strstr($HTTP_USER_AGENT, \"MSIE 6\")) {
$browser = \"Microsoft Internet Explorer 6\";} // MSIE6
else if(strstr($HTTP_USER_AGENT, \"MSIE 5\")){
$browser = \"Microsoft Internet Explorer 5\";} // MSIE5
else if(strstr($HTTP_USER_AGENT, \"MSIE 4\")){
$browser = \"Microsoft Internet Explorer 4\";} // MSIE4
else if(strstr($HTTP_USER_AGENT, \"Netscape6\")){
$browser = \"Netscape Navigator 6\";} // NS6
else if(strstr($HTTP_USER_AGENT, \"Mozilla/4\")){
$browser = \"Netscape Navigator 4\";} // NS4
else if(strstr($HTTP_USER_AGENT, \"Mozilla/5\")){
$browser = \"Mozilla\";} // Mozilla
else if(strstr($HTTP_USER_AGENT, \"Opera/6\")){
$browser = \"Opera\";} // Opera
else {
$browser = \"an unknown browser\";} // Unknown
};
print \"You're Using \".$browser.\".\n\";
?>
:jump:
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.