1

別のホームページからのリンクがクリックされたときに (アンカー「www.mysite.html#slider3」など)、flexslider に特定の画像を表示することは可能ですか? テキストリンクのあるページがあります。ユーザーが「スライダー 3 に移動」などのリンクをクリックすると、flexslider のあるサイトが表示され、スライダー 3 が表示されます。

誰か助けてください。私はすでにこのスレッド ( jQuery FlexSlider - Link to specific image ) を読んでいますが、これはうまくいきません。理由はわかりません。

私の悪い英語について感謝し、申し訳ありません、CeDe

4

2 に答える 2

2

Flexslider は、最初に表示するスライドを表すインデックスを受け入れる「startAt」というプロパティを提供します。また、'slideshow' パラメータを false に設定して、スライドショーの自動再生を無効にすることもできます。スライドショーを作成する前に開始したいスライド参照を取得する場合は、これらのパラメーターを使用できます。

// create a variable to store the slide index to start at.
startAtSlideIndex = 0;

// see if a tab anchor has been included in the url
if (window.location.hash != '') {

  // Set the startAtSlideIndex variable to one less than the ordinal passed
  // note: if you have more than 9 slides, this will fall down and you'll
  //       have to do some more complex string manipulation.
  //       A querystring variable might be easier, especially if you use
  //       someone else's url parser ;)
  // Important: assumes the format of the hash is '#tabN' where N is the digit we want.
  startAtSlideIndex = window.location.hash.substr(4,1)-1;
}

$("#flexslider-container").flexslider({

  // other flexslider params

  // set the flexslider startAt param to the value of the startAtSlideIndex variable
  startAt: startAtSlideIndex

});

編集:元の回答で、場所オブジェクトに「ハッシュ」プロパティがあることを忘れていました。

于 2013-04-11T17:15:13.580 に答える
1

また私です :-) 9 枚以上のスライドでも動作するようです: コードを少し変更しただけです:

// Important: assumes the format of the hash is '#tabNN' where NN is the digit we want. startAtSlideIndex = window.location.hash.substr(4,2)-0;

ありがとうございます!

于 2013-06-17T08:36:43.913 に答える