2011-12-21 40 views
1

我正在使用jQuery Tools的Scrollable作为浏览整个单页网站的手段。如何使用jQuery工具的可滚动深度链接

导航看起来是这样的:

<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'}); 

所以导航水平移动到正确的页面,但散不走的网址,也不能链接到幻灯片。

基本上,我怎么既可以深入链接,也可以使用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

你应该让'如果(哈希==“#联系“)'现在你问'如果哈希不是#联系.' – 2011-12-22 17:08:12

+0

呃!谢谢。 – Keefer 2011-12-22 17:17:20

回答

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 
} 
+0

听起来很有希望。不幸的是,我不知道该怎么做。任何机会,你可以张贴一些抓取URI的例子代码片段,并做scrollTo? – Keefer 2011-12-21 19:52:11

+0

你使用PHP吗? – 2011-12-21 19:55:07

+0

是的。 PHP&jQuery – Keefer 2011-12-21 20:50:43