Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 149
  • Last Modified:

Opening item from Select List in new window

I want to have a 'select' tag on my HOME web page that provides a 'quick navigation' feature - when a visitor clicks a 'Topic' in the select list, I want the topic page to open in a NEW WINDOW.

I have tried a 'jump menu', but this defaults the target to 'parent'. Changing this item to '_blank' has no effect and the targetted page still opens in the original window.

All of my efforts with select tags and jump menus just result in the 'parent' window being used.

To prevent a proliferation of open windows, I would prefer the target to open in a 'Named' window, but other alternatives could be to open in '_blank' or in a window created by a javascript function.

Also, would it be necessary to use '<form>' and '</form>' tags to enclose the visible components?

thanks

nedwob
0
nedwob
Asked:
nedwob
1 Solution
 
dorwardCommented:
If you must use a <select> element as a navigation tool, you should first read:

http://www.cs.tut.fi/~jkorpela/forms/navmenu.html

To open a new window, change:

<form ...> to <form ... target="_blank">

and alter the JavaScript so that:

   window.location.href=URL (or whatever)

becomes

   window.open(URL)
0
 
abridgeCommented:
This works for me - it also allows you to apply features to the new window

<script language="JavaScript" type="text/javascript">
function go1(winName,features){
if (document.selecter1.select1.options[document.selecter1.select1.selectedIndex].value != "none") {
window.open(document.selecter1.select1.options[document.selecter1.select1.selectedIndex].value,winName,features);
          }
     }
</script>
<form name="selecter1"><select name="select1" size=1 onchange="go1('WindowName','width=270,height=330')">
<option value=none>Select your destination
<option value=none>--------------------
<option value="here.htm">here
<option value="there.htm">there
</select>
</form>

:)
0
 
whammyCommented:
<html>
<head>
   <title>Open a new window with a dropdown using javascript!</title>
<script type="text/javascript">
<!--
function openWindow(val) {
   if(val) {
      myWin = window.open(val,"myWin");
      window.myWin.focus();
   }
}
// -->
</script>
</head>
<body>
   <form id="form1" action="javascript:void 0">
      <select name="myselect" onchange="openWindow(this.options[this.selectedIndex].value)">
         <option value="">Choose a website!</option>
         <option value="http://www.google.com">Google it!</option>
         <option value="http://www.yahoo.com">Yahoo!</option>
         <option value="http://www.download.com">Find a cool program!</option>
      </select>
   </form>
</body>
</html>
0
 
nedwobAuthor Commented:
Thanks to all who answered. I decided to accept the comment from 'dorward' because the link he provided has given me a lot of useful information.

nedwob
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now