Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Oct 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    help? can redirect..

    what wrong, it just adds the website to the end of the address bar, and it doesnt redirect???help please
    <html>
    <head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    </head>
    <body>
    <div>
    <h1>hello</h1>
    <form onsubmit="return go();">

    <select name="website" id="website">
    <option value="http://www.google.com/">google.com</option>
    <option value="www.yahoo.com">yahoo.com</option>
    </select>
    <script type="text/javascript">
    function go() {
    var s = getElementById("website");
    window.location = s.options[s.selectedIndex].value;
    return false; //prevents the form from being submitted to the server.

    }
    </script>
    <input type="submit">
    </form>
    </div>
    </body>
    </html>

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,857
    Thanks
    78
    Thanked 4,418 Times in 4,383 Posts
    You forgot the http:// in front of "www.yahoo.com".

    It should work to take you to google, as written, but not to yahoo.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #3
    Regular Coder
    Join Date
    Sep 2011
    Posts
    103
    Thanks
    0
    Thanked 14 Times in 14 Posts
    Hi,

    Please prefix http:// in front of any other domain url like as you did in http://www.google.com/.

    It works


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •