Javascript javascript重定向到新窗口

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11694753/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-24 06:45:34  来源:igfitidea点击:

javascript redirect to new window

javascriptredirect

提问by user1022585

I have this code that redirects to a page based on the value of a dropdown list:

我有这个代码根据下拉列表的值重定向到一个页面:

<Script language="JavaScript">
function goto(form) { var index=form.select.selectedIndex
if (form.select.options[index].value != "0") {
location=form.select.options[index].value;}}
//-->
</SCRIPT>

How do I make that open in a new window?

如何在新窗口中打开它?

回答by j08691

function goto(form) {
    var index = form.select.selectedIndex
    if (form.select.options[index].value != "0") {
        location = form.select.options[index].value;
        window.open(location);
    }
}?

For the full list of options available to window.open, see https://developer.mozilla.org/en/DOM/window.open

有关 可用选项的完整列表window.open,请参阅https://developer.mozilla.org/en/DOM/window.open

回答by Yash Vekaria

Make javascript function :-

制作 javascript 功能:-

 onBtnPress:function(){
        window.open("http://www.yashvekaria.com", "_blank");
    }

回答by wanovak

window.open(URL,name,specs,replace)

url: URL for new window

url: 新窗口的 URL

name: (optional) default is _blank

名称:(可选)默认为 _blank

specs: (optional) Google JavaScript window.open for a complete list

规格:(可选)Google JavaScript window.open 获取完整列表

replace: (optional) [true|false] replace history or append

替换:(可选)[true|false] 替换历史记录或追加

回答by Drawyan

window.open(url, "nameOfTheWindow");

Check http://www.w3schools.com/jsref/met_win_open.aspto see the detailed options, most browsers support this, but some of them dones't work well with sizing the popup window.

检查http://www.w3schools.com/jsref/met_win_open.asp以查看详细选项,大多数浏览器都支持此功能,但其中一些无法很好地调整弹出窗口的大小。

回答by Jiarong Xu

window.open(URL,name,specs,replace)

Check herefor detailed usage of this.

在这里对本详细的使用。