admin管理员组

文章数量:1193313

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?

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?

Share Improve this question asked Jul 27, 2012 at 19:49 user1022585user1022585 13.6k23 gold badges57 silver badges76 bronze badges 2
  • Exact duplicate of several other questions. Did you search before you asked? – Stephen P Commented Jul 27, 2012 at 19:58
  • possible duplicate of How can I make a redirect page in jQuery/JavaScript? – Hailwood Commented Jul 30, 2012 at 11:32
Add a comment  | 

5 Answers 5

Reset to default 17
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");

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

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

Check here for detailed usage of this.

本文标签: javascript redirect to new windowStack Overflow