我該如何正確檢查當前頁面的URL,以及該URL是否在數組中爲頁面設置動畫效果?以下是我到目前爲止,但每個頁面動畫不只是在我的數組中。基於url的動畫頁面
此腳本加載在頁腳的每個頁面上。
我相信這很簡單,但我有限的JS知識。謝謝!
var pageArray = new Array("/how-it-works.php", "/themethodology.php", "/thecommunity.php","/thetools.php");
var currrentPage = window.location.pathname;
if (jQuery.inArray(jQuery('currrentPage'), pageArray)){
$('html, body').animate({
scrollTop: $("#pageheader_cont").offset().top
}, 1000);
}
你是什麼意思*「每頁動畫」* ..?一個網址打開一頁,右.. ..? 0.o – 2014-09-26 07:11:03
對不起,我不是更清楚。點擊加載我的導航中的每一頁。但頁面,但它不應該動畫,除非該頁面在數組中。 – Denoteone 2014-09-26 07:41:34
請更新問題並在其中添加額外信息,而不是在評論中。那麼,你在所有頁面上都有相同的腳本? – 2014-09-26 08:08:02