html - 输入 onclick 新标签

标签 html onclick

<form name="test">
<select name="choose" style="width:300px;">
<option selected="">Select option</option>
<option value="http://url.com">Test</option>
</select>
<input onclick="location=document.test.choose.options[document.test.choose.selectedIndex].value;" value="Take me there!" type="button"></p>
</form>

我使用以下内容制作下拉列表,只是想知道如何在新选项卡中而不是在其自己的窗口中打开所选内容

工作正常,因为它只需要在新标签页中打开。

* 编辑 *

这按需工作谢谢

<input onClick="window.open(document.test.choose.options[document.test.choose.selectedIndex].value);" value="Take me there!" type="button">

最佳答案

试试window.open

window.open('http://www.google.com');

更新

现场演示 - http://jsfiddle.net/im4aLL/tzp4H/

关于html - 输入 onclick 新标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16786813/

相关文章:

jquery - 使用 jQuery 来回更改 html 内容

jquery - 为什么我不能选择 use .play() 使用 jQuery 选择视频?

javascript - Accordion 在 IE6 中乱七八糟

html - 在 cookie 中存储 OAuth token 是不好的做法吗?

javascript - 通过鼠标控制窗口移动

java - Android - 将值从 HTML 或 Javascript 传递到 Java 的最简单方法?

javascript - 将 JSON 的 php 字符串(带引号)传递给 onclick 函数

自动运行按钮上的Javascript "onclick"属性

JavaScript/jQuery : how to catch a click that targets any element except for several specified elements?

jquery - 在没有命名空间的jquery中触发事件