1

単一ページのサイト全体をナビゲートする手段として、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 メッセージを 2 回エコーします。URL の現在のハッシュ タグをそのままエコーするべきではありませんか?

4

1 に答える 1

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
}
于 2011-12-21T16:15:49.333 に答える