我的頁面頂部有一個鏈接到/#選項卡(index id =「tabs」)的按鈕。它使用腳本來很好地滾動到id,但它將URL更改爲www.domain.com/#tabs
我怎樣才能提取#tabs
部分?我正在考慮在.htaccess
這樣做,但不知道這是否可能,它是一個好主意。無需更改網址即可定位的HTML鏈接
繼承人的HTML:
<a class="smoothscroll" href="/#tabs">
<div class="scroll-down"></div>
</a>
</header>
<br />
<div id="tabs" style="padding:20px;"></div>
<div class="tabs">
<h1>About</h1>
<div class="p">
about us
<a href="/contact"><input type="submit" value="Contact Us" class="btn" name="contact" style="min-width:15%;"/></a>
</div>
</div>
<a class="smoothscroll" href="/#tabs">
<div class="scroll-down"></div>
</a>
是按鍵部分,它使用這個腳本,滾動順暢
<script>
/*----------------------------------------------------*/
/* Quote Loop
------------------------------------------------------ */
function fade($ele) {
$ele.fadeIn(1000).delay(3000).fadeOut(1000, function() {
var $next = $(this).next('.quote');
fade($next.length > 0 ? $next : $(this).parent().children().first());
});
}
fade($('.quoteLoop > .quote').first());
/*----------------------------------------------------*/
/* Smooth Scrolling
------------------------------------------------------ */
jQuery(document).ready(function($) {
$('.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;
});
});
});
TweenMax.staggerFrom(".heading", 0.8, {opacity: 0, y: 20, delay: 0.2}, 0.4);
</script>
只是忘了腳本的頂部,這就是隻是索引的一部分。
參見:http://stackoverflow.com/a/5298684/290343 – jlynch630
你怎麼樣只是刪除_explicitly sets_滾動後的哈希值進行行... ? – CBroe