简体   繁体   中英

javascript redirect to new window

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?

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

Make javascript function :-

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

url: URL for new window

name: (optional) default is _blank

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

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

window.open(url, "nameOfTheWindow");

查看http://www.w3schools.com/jsref/met_win_open.asp以查看详细选项,大多数浏览器都支持此功能,但其中一些选项在调整弹出窗口大小时效果不佳。

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

点击此处查看详细用法。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM