响应选择菜单目标_blank

时间:2012-11-21 23:40:05

标签: jquery html responsive-design

您好我有一个有效的响应选择菜单,我希望能够只做一个链接目标_blank

<select onchange="if (this.value) window.location.href = this.value;">

    <option value="" selected="selected">Navigation</option> 
    <option value="#">Home</option> 
    <option value="lessons/">Lessons</option> 
    <option value="locations/">Locations</option> 
    <option value="accomodation/">Accommodation</option> 
    <option value="holidays/">Holidays</option> 
    <option value="shop/">Shop</option> 
    <option value="contact/">Contact</option> 
    <option value="kite-jobs/">Jobs</option> 

</select>

2 个答案:

答案 0 :(得分:0)

在您需要的情况下使用window.open()

<select onchange="if (this.value === 'accomodation') window.open(this.value, '_blank') else if (this.value) window.location.href = this.value;">

答案 1 :(得分:0)

<select>

    <option value="" selected="selected">Navigation</option> 
    <option value="#">Home</option> 
    <option value="lessons/">Lessons</option> 
    <option value="locations/">Locations</option> 
    <option value="accomodation/">Accommodation</option> 
    <option value="holidays/">Holidays</option> 
    <option value="shop/">Shop</option> 
    <option value="contact/">Contact</option> 
    <option value="kite-jobs/">Jobs</option> 

</select> 
$(function(){
    $('select').on('change', function() {  
      var url = this.value;  
      if(url == 'shop/' ){            // or whatever
        window.open(url, '_blank');
      }else{
        window.location.href = url;
      }    
    });
});