在新窗口中打开dd菜单选择 [英] open dd menu selection in new window

查看:151
本文介绍了在新窗口中打开dd菜单选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在下拉菜单中使用以下代码,但我希望所选选项在新窗口中打开。我应该如何更改此代码以使其正常工作?

I'm using the following code for a drop down menu but I want the selected option to open in a new window. How should I change this code to make this work?

<form name="blah_blah">
<select name="ddmenu_name" style="width: 80% !important;">
<option value="first_option_name" selected>option display name</option>
<option value="1st link to content">1st option name</option>
<option value="2nd link to content">2nd option name</option>
</select>
<input type="button" name="Submit" value="Go!" onClick="top.location.href = this.form.ddmenu2.options[this.form.ddmenu2.selectedIndex].value;
return false;">
</form>

谢谢!

推荐答案

见下文...

index.html

<html>
<body>
<form name="blah_blah">
<select name="ddmenu_name" id="ddmenu_name" style="width: 80% !important;">
<option value="first_option_name" selected>option display name</option>
<option value="page1.html">1st option name</option>
<option value="page2.html">2nd option name</option>
</select>
<input type="button" name="Submit" value="Go!" onClick="window.open(ddmenu_name.value,'newtab')">
</form>
</body>
</html>

page1.html

<html>
<body>
Page 1
</body>
</html>

page2.html

<html>
<body>
Page 2
</body>
</html>

希望这是你需要的!!!

Hope this is what you needed!!!

祝你好运!!!

更新1

如果你想选择选项后快速打开新窗口(而不是按Go按钮),下面是代码

If you want to open new window quickly after selecting option (and not pressing Go button), below is code

<html>
<body>
<form name="blah_blah">
<select name="ddmenu_name" id="ddmenu_name" style="width: 80% !important;"  onChange="window.open(ddmenu_name.value,'newtab'">
<option value="first_option_name" selected>option display name</option>
<option value="page1.html">1st option name</option>
<option value="page2.html">2nd option name</option>
</select>
</form>
</body>
</html>

这篇关于在新窗口中打开dd菜单选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆