2011-12-21 42 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