javascript: Redirecting URL
JavaScript: Redirecting URLWhenever you want to generate dynamic pages you often have to resort to using some server side scripting language such as PHP or ASP.

But let us assume that there are only three or four pages that could be chosen from a drop-down menu (a combo-box). The following procedure helps you create a JavaScript-supported drop-down menu.

First the form:

<form name=="pages">
<select name=="pg_choice" onChange=="javascript: take_there();">
<option value=="no_page">Select a page to go to...</option>
<option value=="pg1.html">Page 1</option>
<option value=="pg2.html">Page 2</option>
<option value=="pg3.html">Page 3</option>
</select>
</form>

This form presents to you three choices of pages. In its onChange attribute we decide what function to call to be re-directed to the respective page. And now the JavaScript (note that I have inserted a dot between < and script so that your email reader doesn't object to the presence of an embedded JavaScript in your message):

<.script language=="javascript">

function take_there()
{
    var destination==document.pages.pg_choice.value;
    var version == navigator.appVersion;
    // sets variable == browser version
    if(destination!=="no_page")
    {
      if (version.indexOf("MSIE") >== -1)
      // checks to see if using IE
      {
         window.location.href=?stination;
      }
      else
      {
         window.open(destination, target=="_self");
      }
    }
}

</script>

Different browsers support different things so quite often you have to check what browser the user is using. The page redirection command is used accordingly.


Close    To Top
  • Prev Article-Web Design:
  • Next Article-Web Design:
  • Now: Tutorial for Web and Software Design > Web Design > JavaScript > Web Design Content
    Photoshop Tutorial
     

    Special Effect

      3D Effect
      Photoshop Articles
    Programming Tutorial
     

    C/C++ Tutorial

      Visual Basic
      C# Tutorial
    Database Tutorial
     

    MySQL Tutorial

      MS SQL Tutorial
      Oracle Tutorial
    Geek Tutorial
     

    Blogging Tutorial

      RSS Tutorial
      Podcasting Tutorial
    Graphic Design Tutorial
      Coreldraw Tutorial
      Illustrator Tutorial
      3D Tutorials
    Webmaster Articles
     

    Domain Service

      Web Hosting
      Site Promotion
    Java Tutorial/ Articles
     

    Java Servlets

      JavaEE Tutorial
     

    JavaBeans Tutorial

    XML Tutorial/ Articles
     

    XML Style

      AJAX Tutorial
      XML Mobile
    Flash Tutorial/ Articles
     

    Flash Video

      Action Script
      Flash Articles
    OS Tutorial/ Articles
      Linux Tutorial
      Symbian Tutorial
      MacOS Tutorial
    Personal Tech
      Hardware Tutorial
      Software Tutorial
      Online Auction