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 4 of 4
  1. #1
    New Coder
    Join Date
    Apr 2003
    Posts
    65
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Opening a Select Menu Link in a New Window

    I have the following html select menu - I want to be able to open some of the links in there own windows. I tried to use target="_blank" but could not get it to work.


    <form>
    <td>
    <select id="UserGroups" name="shortcut" onChange="if (this.form.shortcut[this.form.shortcut.selectedIndex].value) window.location=this.form.shortcut[this.form.shortcut.selectedIndex].value;" style="font: 10px verdana, arial, sans-serif; color: #636163; text-decoration: none;">
    <option value="">Navigation >></option>
    <option value="1.asp">Link 1</option>
    <option value="2.asp">Link 2</option>
    <option value="3.asp">Link 3</option>
    <option value="4.asp">Link 4</option>
    </select>
    </td>
    </form>

  • #2
    teh Moderatorinator
    Join Date
    Sep 2004
    Location
    USA
    Posts
    2,472
    Thanks
    4
    Thanked 40 Times in 40 Posts
    You could use window.open();

  • #3
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,068
    Thanks
    0
    Thanked 256 Times in 252 Posts
    Code:
    <form>
    <td>
    <select id="UserGroups" name="shortcut" onChange="doOpen(this)" style="font: 10px verdana, arial, sans-serif; color: #636163; text-decoration: none;">
    <option value="">Navigation >></option>
    <option value="_blank|1.asp">Link 1</option>
    <option value="_self|2.asp">Link 2</option>
    <option value="_self|3.asp">Link 3</option>
    <option value="_self|4.asp">Link 4</option>
    </select>
    </td>
    </form>
    <script type="text/javascript">
    function doOpen(oSel){
      var strValue = oSel.options[oSel.selectedIndex].value;
      if (strValue){
        var arr = strValue.split("|");
        var w = window.open(arr[1], arr[0]);
        w.focus();
      }
    }
    </script>
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #4
    New Coder
    Join Date
    Apr 2003
    Posts
    65
    Thanks
    0
    Thanked 0 Times in 0 Posts
    glenngv -

    Worked perfectly, thanks for your help!


  •  

    Posting Permissions

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