Browser Detector HTML

mayo

Beta member
Messages
4
Hey guys, I apologize if this subject has been covered before, I searched for it, and couldn't fine anything similar.

I have a website that I want it to only be viewed by firefox users. I want it so if you have firefox, you will be directed to the site, and if not, you will be directed to a different page. I know it's possible, because I have seen it on several websites I have entered.

Thank you in advance. :)

- Mayo
 
Google? But Anyway:

Code:
<html>
  <script>
  if(navigator.userAgent.indexOf("Firefox") != -1)
  {
     window.location = "http://www.i-code.co.uk";
  }
  else
  {
     window.location = "http://www.mozilla.org/products/firefox/";
  }
  </script>
  </html>
 
May I ask why you only want Mozilla user's? Good design will support whatever the user throws at it. It would probably be better to have a code in javascript that detects the browser and renders elements on the page differently. If it's a matter of a style problem for example: Firefox does not support the double property for border, whereas IE does. Let's assume we have a div tag on the page and we want to give it a border. fix:
Code:
<head>
<script type="text/javascript">
<!-- if the browser can't read javascript we put the comments here so that the code is not rendered as text
function checkBrowser() {
if(navigator.appName("Firefox") {
document.getElemetById("mainDiv").Style.add("border-style", "solid");
}
else {
document.getElementById("mainDiv").Style.add("border-style", "double");
}
}
// stop hiding -->
</script>
</head>
<body onLoad="checkBrowser();">
<div id="mainDiv" style="border-style: solid; border-width: 1px; border-color: #000000; padding: 5px; height: 100px; width: 100px; position: absolute; top: 50px; left: 135px;">
This is a test
</div>
</body>
 
Daeva said:
May I ask why you only want Mozilla user's? Good design will support whatever the user throws at it. It would probably be better to have a code in javascript that detects the browser and renders elements on the page differently. If it's a matter of a style problem for example: Firefox does not support the double property for border, whereas IE does. Let's assume we have a div tag on the page and we want to give it a border. fix:
At first I wanted it to be firefox because that is the browser i was using when making the website in dreamweaver. Later on, I found out that the website is messed up when viewed from IE. So I changed it so it's compatible with IE. Now, it looks relatively ok for both browsers, a bit messed up on firefox.
I need that code anyway for another part of the site. Thank you very much, it helped a lot :)
 
Back
Top Bottom