我使用jQuery Tools的Scrollable作为浏览整个单页网站的方法。
导航看起来像这样:
<div id="mainNavContainer">
<nav>
<a id="logo" href="#home" title="Hughes Opticians, Delmar, NY"></a>
<a href="#who-we-are" title="Who We Are">Who We Are</a>
<a href="#eye-exams" title="Eye Exams">Eye Exams</a>
<a href="#gallery" title="Gallery">Gallery</a>
<a href="#eyewear" title="Eyewear">Eyewear</a>
<a href="#contact-lenses" title="Contact Lenses">Contact Lenses</a>
<a href="#contact" title="Contact">Contact</a>
</nav>
</div>
jQuery解雇它看起来像这样:
$("#homeScrollable").scrollable({circular:true, next:'.mainNext', prev:'.mainPrev'}).navigator({navi:'#mainNavContainer nav'});
因此导航水平移动到正确的页面,但哈希不会转到URL,也不能链接到幻灯片。
基本上,我怎样才能深度链接,还可以使用nav作为插件的导航器目标?
回应下面的回复,
我试过这个测试:
var hash = self.document.location.hash.substring(1) ;
if(hash == "home"){
console.log('Home page')
}
if(hash == "who-we-are"){
console.log('Who we are page')
}
if(hash == "eye-exams"){
console.log('Eye Exams page')
}
if(hash == "gallery"){
console.log('Gallery page')
}
if(hash == "eyewear"){
console.log('Eyewear page')
}
if(hash == "contact-lenses"){
console.log('Contact Lenses page')
}
if(hash == "contact"){
console.log('Contact page')
}
控制台两次回显每个console.log消息。它不仅应该回显我的URL的当前哈希标记吗?
答案 0 :(得分:1)
回到我之前的回答,我发现了一些整洁的东西:
unescape(self.document.location.hash.substring(1));
所以你可以这样做:
//onload
var hash = self.document.location.hash.substring(1) ;
if(hash != ""){
//Run your scrollto code with the hash var
}