window.location与window.open问题

时间:2013-06-17 21:41:47

标签: javascript jquery

我有一行下拉列表网址重定向的代码,工作正常我需要在新标签中打开网址,我做了一些搜索,发现window.location的替代方法是窗口。开放,但所以我把代码更改为我认为合乎逻辑的但我知道某些事情不对,但我目前没有解决它的知识。

 $(function () {
        // get your select element and listen for a change event on it
        $('#selectEl').change(function () {
            // set the window's location property to the value of the option the user has selected
            //window.location = $(this).val();
              window.open($(this).val(););
        });
    });

HTNL

<form name="form1">
                        <select name="select" size="1" id="selectEl">
                            <option value="">I would like to login to...</option>
                            <option value="client_login">Secure Login</option>
                             <option value="https://login.xero.com/">Xero Login</option>
                            <option value="https://secure.saasu.com/a/login">Saasu Login</option>
                           <option value="https://businessaccounting.banklinkonline.com">BankLink Login</option>
                        </select>
                    </form>

1 个答案:

答案 0 :(得分:3)

删除额外的;

 window.open($(this).val());

演示---> http://jsfiddle.net/PqXWJ/21/show/