选项框不会重定向到Safari中的其他页面

时间:2014-10-20 13:58:09

标签: javascript select option

我有一个选项选项框的脚本,当单击该选项时会重定向到新页面,但它在Safari浏览器上不起作用。在Firefox和Chrome上看起来没问题 - 请帮忙!

示例html:

<select name="features" id="features" >
        <option Selected="">Software Features</option>
        <option value="http://yahoo.com">See All Features</option>
        <option value="http://google.com">Feature 1</option>
        <option value="http://bing.com">Feature 2</option>
        <option value="http://ask.com">Feature 3</option>
    </select>

然后就是脚本:

<script>
    document.getElementById("features").onchange = function() {
        if (this.selectedIndex!==0) {
            if (this.value.indexOf('http://') == 0) {
                window.open(this.value);
            }
            else {
                window.location.href = this.value;
            }
        }
    };
   </script>

0 个答案:

没有答案