Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

redirect if browser is not expected

Status
Not open for further replies.

addievt

Technical User
Jan 16, 2008
2
US
ok well so far i have a working browser check

<script type="text/javascript">
var browser=navigator.appName;
var b_version=navigator.appVersion;
var version=parseFloat(b_version);

document.write("Browser name: "+ browser);
document.write("<br/>");
document.write("Browser version: "+ version);
</script>

but i want it to redirect if the browser is not firefox, i dont know how to do this so please help.
-addie
 
Try using userAgent instead of appName:
Code:
<script type="text/javascript">
if (navigator.userAgent.indexOf("Firefox")>-1) {
   location.href="[URL unfurl="true"]http://www.tek-tips.com";[/URL]
}
</script>
Hope that helps!

Cheers,
Jeff

[tt]Jeff's Blog [!]@[/!] CodeRambler
[/tt]

Make sure your web page and css validates properly against the doctype you have chosen - before you attempt to debug a problem!

FAQ216-6094
 
well i accidentally put firefox, i meant playstation 3
(the code i gave shows "PLAYSTATION 3" as the appName)
so i didnt bother changing firefox, because i knew i could switch it out.

and i need it to only work on ps3 because i can protect music and files so only ps3s can stream them (thus meaning no pirating) (except from hackers of course =p )

also, i couldnt get that code to work no matter how hard i tried >.< it just went to the page and stayed there
 
So user that have disabled javascript will be able stream and the gamers on PS3 too.

Christiaan Baes
Belgium

My Blog
 
>> (except from hackers of course =p )

Ignore chrissie1. He's one of the hackers that's allowed to stream your content.

-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
Or people who simply change their user agent string.

Never be afraid to share your dreams with the world.
There's nothing the world loves more than the taste of really sweet dreams.

Webflo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top