繁体   English   中英

window.location与window.open问题

[英]window.location vs window.open issue

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

 $(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>

删除额外的;

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

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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