2017-12-06 1 views
0

기본 jquery 문제가 있습니다. 그냥이 링크를 새 탭/창에서 열려고합니다. _blank를 추가했지만 새 페이지로 이동하지 않습니다. 어떤 아이디어? HTML에서내 버튼으로 새 탭을 열 수 있습니까?

$('#link13').click(function() { 
 

 
    window.location.href= 'https://www.google.com','_blank'; 
 

 
    });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> 
 
<button type="button" class="btn btn-primary" id="link13">See the Resources</button>

+0

이'의 window.open을 시도해보십시오 브라우저 구현에 따라 '은 https : //www.google.com','_blank '); –

답변

0
$('#link13').click(function() { 
    window.open(
     'https://www.google.com', 
     '_blank' // <- This is what makes it open in a new window. 
    ); 
}); 
0

당신은 다음과 같은 사용할 수 있습니다

<button class="btn btn-success" onclick=" window.open('http://google.com','_blank')"> Google</button>

순수 HTML 방법 :

<a href="https://google.com" target="_blank">Google</a>

1

사용 window.open():

var win = window.open('https://www.google.com','_blank'); 
if (win) { 
    //Browser has allowed it to be opened 
    win.focus(); 
} else { 
    //Browser has blocked it 
    alert('Please allow popups for this website'); 
} 

(이 .. 도움이된다면 이 볼 작동

관련 문제