我这里遇到了一些困难。我想将一个
每次在新标签页中打开新链接时,我得到的是:file:///C:/PASSIS%20-%20Landing%20Page/google.com。
<a>
标签设置为外部 URL,但每次设置后,链接中都会添加包含该 URL 的 index.html 的本地路径。我已经查看了我的 jQuery 代码,似乎没有发现问题。我甚至使用 console.log(url) 进行测试,它正确地返回了 URL。
$('.smoothscroll').on("click", function() {
if (nav.hasClass('mobile')) nav.fadeOut('fast');
})
$('.smoothscroll').on('click', function (e) {
e.preventDefault();
var target = this.hash,
$target = $(target);
$('html, body').stop().animate({
'scrollTop': $target.offset().top
}, 800, 'swing', function () {
window.location.hash = target;
});
});
$('#login').on('click', function (e){
e.preventDefault();
var url = $(this).attr('href');
window.open(url, '_blank');
});
<ul id="nav" class="nav">
<li class="current"><a class="smoothscroll" href="#hero">Home.</a></li>
<!--<li><a class="smoothscroll" href="#portfolio">Works.</a></li>-->
<li><a class="smoothscroll" href="#about">About Us.</a></li>
<li><a class="smoothscroll" href="#portfolio">Features.</a></li>
<li><a class="smoothscroll" href="#contact">Create Account.</a></li>
<li><a class="login" id="login" href="google.com">Login.</a></li>
</ul>
http://
或https://
。有时这会导致问题。 - Script47