我有一个基本的jquery问题。只是尝试在新的标签/窗口中打开此链接。我添加了_blank但它没有进入新页面。有什么想法吗?
$('#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 :(得分: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');
}
根据浏览器的实现情况,这将有效 如果它有帮助,请看这个..
答案 1 :(得分:0)
在HTML中,您可以使用以下内容:
<button class="btn btn-success" onclick=" window.open('http://google.com','_blank')"> Google</button>
纯HTML方法:
<a href="https://google.com" target="_blank">Google</a>
答案 2 :(得分:0)
$('#link13').click(function() {
window.open(
'https://www.google.com',
'_blank' // <- This is what makes it open in a new window.
);
});