2
我的網頁上有一個javascript來檢查最後一個或最後一個URL是否包含字符串,但是每個條件都返回TRUE,無論我來自哪個網址。檢查前一個(-1&-2)url是否包含字符串
你能幫我解釋一下嗎?如果我從if中除去其他條件,則所有條件都變爲TRUE。
這是謝謝你的頁面。從訂購頁面(我檢查的url)重定向用戶到/ dekuji-vam(這個感謝頁面),因爲我必須在條件下使用-2。
感謝你的幫助, 米哈爾
$(document).ready(function() {
if((window.location.href.indexOf("kurz-chytre-seo") > -1) || (window.location.href.indexOf("kurz-chytre-seo") > -2)) {
window.history.pushState('dekuji-vam', 'Děkuji Vám', 'http://www.pavelungr.cz/skoleni/kurz-chytre-seo/dekuji-vam');
$('.dc1').css('display', 'block');
}
else if((window.location.href.indexOf("vam-workshop-analyzy-klicovych-slov") > -1) || (window.location.href.indexOf("workshop-analyzy-klicovych-slov") > -2)) {
window.history.pushState('dekuji-vam', 'Děkuji Vám', 'http://www.pavelungr.cz/skoleni/workshop-analyzy-klicovych-slov/dekuji-vam');
$('.dc2').css('display', 'block');
}
else if((window.location.href.indexOf("workshop-seo-pro-wordpress") > -1) || (window.location.href.indexOf("workshop-seo-pro-wordpress") > -2)) {
window.history.pushState('dekuji-vam', 'Děkuji Vám', 'http://www.pavelungr.cz/skoleni/workshop-seo-pro-wordpress/dekuji-vam');
$('.dc3').css('display', 'block');
}
else if((window.location.href.indexOf("interni-skoleni-pro-firmy") > -1) || (window.location.href.indexOf("interni-skoleni-pro-firmy") > -2)) {
window.history.pushState('dekuji-vam', 'Děkuji Vám', 'http://www.pavelungr.cz/skoleni/interni-skoleni-pro-firmy/dekuji-vam');
$('.dc4').css('display', 'block');
}
else if((window.location.href.indexOf("seo-pro-copywritery") > -1) || (window.location.href.indexOf("seo-pro-copywritery") > -2)) {
window.history.pushState('dekuji-vam', 'Děkuji Vám', 'http://www.pavelungr.cz/skoleni/seo-pro-copywritery/dekuji-vam');
$('.dc5').css('display', 'block');
}
else if((window.location.href.indexOf("workshop-na-strukturovana-data-rich-snippets-mikroformaty-mikrodata") > -1) || (window.location.href.indexOf("workshop-na-strukturovana-data-rich-snippets-mikroformaty-mikrodata") > -2)) {
window.history.pushState('dekuji-vam', 'Děkuji Vám', 'http://www.pavelungr.cz/skoleni/workshop-na-strukturovana-data-rich-snippets-mikroformaty-mikrodata/dekuji-vam');
$('.dc6').css('display', 'block');
}
else if((window.location.href.indexOf("jak-spravne-udelat-analyzu-klicovych-slov-tvorba-analyzy") > -1) || (window.location.href.indexOf("jak-spravne-udelat-analyzu-klicovych-slov-tvorba-analyzy") > -2)) {
window.history.pushState('dekuji-vam', 'Děkuji Vám', 'http://www.pavelungr.cz/skoleni/jak-spravne-udelat-analyzu-klicovych-slov-tvorba-analyzy/dekuji-vam');
$('.dc7').css('display', 'block');
}
else if((window.location.href.indexOf("jak-spravne-implementovat-analyzu-klicovych-slov-uprava-webu-a-strategie") > -1) || (window.location.href.indexOf("jak-spravne-implementovat-analyzu-klicovych-slov-uprava-webu-a-strategie") > -2)) {
window.history.pushState('dekuji-vam', 'Děkuji Vám', 'http://www.pavelungr.cz/skoleni/jak-spravne-implementovat-analyzu-klicovych-slov-uprava-webu-a-strategie/dekuji-vam');
$('.dc8').css('display', 'block');
}
});
謝謝你,我還以爲這是在以前的網址導航。你不知道我以前的網址可以檢查嗎?它看起來像這個條件不能採取URL我想檢查(從訂單頁面),所以每個條件返回false。 –
[this](http://stackoverflow.com/questions/3528324/how-do-you-get-the-previous-url-in-javascript)可能會給你一些想法,但這不是一件容易的事情 –
再次感謝你, 我會試試看。 –