2016-09-14 1 views
1

이 웹 페이지에 회전 목마가 있습니다. https://stfn.herokuapp.com 거의 완벽하게 작동하며 중앙에있는 기본 (활성) 항목 만 클릭하면 아무 것도하지 않습니다. 리다이렉트해야한다) js 파일과 인덱스에서 링크를 추가하려고 시도했지만 팁을 얻은 사람이 문제를 해결하지 못했습니까?활성 항목을 클릭하면 Jquery 회전식 메뉴가 리디렉션되지 않습니다.

[편집]

그냥했다, 질문을하기 전에 최신 빌드를 업로드 잊으. 그래서 index.html에서 img에 태그를 추가했는데 그 중 하나는 작동하지 않습니다. 여기

$('.carousel .item').click(function(e) { 
     var index = $(this).index('li'); 
     carousel.cycleActiveTo(index); 
     // song3(); 
     e.preventDefault(); 

     if (currentIndex != index){ 
      var difference; 

      if (currentIndex == 0 && index >= 5){ 
       difference = (index - currentIndex) - 13; 
      } else { 
       difference = index - currentIndex; 
      } 

      difference = Math.abs(difference); 
      delay = difference * options.duration; 
      currentIndex = index; 

      console.log(delay); 

      setTimeout(goToLink, delay); 
     } 
    }); 

    goToLink = function() { 
     if (currentIndex == 0) { 
      // console.log("works:"); 
      document.location.href = "about.html" 
     } 
     if (currentIndex == 1) { 
      document.location.href = "blog.html" 
     } 
     else if (currentIndex == 2) { 
      document.location.href = "collection.html" 
     } 
     else if (currentIndex == 3) { 
      document.location.href = "shop.html" 
     } 
     else if (currentIndex == 4) { 
      // alert("ABOUT2"); 
      document.location.href = "about.html" 
     } 
     else if (currentIndex == 5) { 
      document.location.href = "blog.html" 
     } 
     else if (currentIndex == 6) { 
      document.location.href = "collection.html" 
     } 
     else if (currentIndex == 7) { 
      document.location.href = "contact.html" 
     } 
     else if (currentIndex == 8) { 
      document.location.href = "shop.html" 
     } 
     else if (currentIndex == 9) { 
      document.location.href = "contact.html" 
     } 
     else if (currentIndex == 0) { 
      document.location.href = "about.html" 
     } 
    } 

}); 

그래서 당신이 볼로 JS 파일에서 방향 전환 코드 스 니펫의 모든 요소는 할당 된 인덱스를 가지고 있으며, 그것은 특정 페이지로 전환 할 수 있습니다. 활성 항목의 색인 번호는 0이지만 다른 항목처럼 작동하지 않는 것 같습니다.

+0

일부 코드를 보여줍니다. 물론 아무것도하지 않습니다. 'img'에는 링크가 없습니다. –

+0

오, 최신 빌드를 업로드하는 걸 잊었습니다. 또한 방향 전환을 담당하는 코드를 추가했습니다. –

+0

'goToLink' fn이 끔찍합니다. : D는 링크/페이지를 배열에 넣고'document.location.href = linkArray [currentIndex]'를 호출합니다. –

답변

1

if (currentIndex != index){ < - 두 항목 모두 0이므로이 항목은 거짓입니다. 검사가 동일한 경우

은 그래서 당신은 다른 필요와 고토 메소드를 호출 아무것도

하지 않습니다.

if (currentIndex != index){ 
    ... the code ... 
} else { 
    goToLink(); 
} 
+0

감사합니다 요리사, 그것이 그렇게 단순했다라고 생각할 수 없다. .. –