Welcome to Anythingweb.org  
You are not Logged in! Log in to check your messages.

Today's:
Popular Articles and Posts:

Load Page Depending on Browser Type


In this tutorial I will teach you how to load a certain webpage depending upon what type of browser your user is using. This could be helpful because certain browsers handle css, html, and javascript differently. Lets begin with the tutorial!

First lets start with some javascript tags.

<script>

</script>

Next within the javascript tags, paste the following code

if (navigator.appName == "Microsoft Internet Explorer"){
      document.write('<META HTTP-EQUIV="REFRESH" CONTENT="2;URL=example.html">');
}else
      document.write('<META HTTP-EQUIV="REFRESH" CONTENT="2;URL=example2.html">');

In this code, the first thing we do is check to see if the user is using Microsoft Internet Explorer. If the user is using Microsoft Internet Explorer we use META HTTP-EQUIV which specifies a delay in seconds, 2 in this case, before the browser automatically reloads the page with the URL specified. If the user is not using Microsoft Internet Explorer, the code will direct them to example2.html.

You can add more to this code to test if users are using Firefox, Netscape, Opera, Safari, or anyother browser. That is it, you should be able to test this code and use it any way you like.

    Demo Of The Code