[英]Back button with multiple steps and different urls in Javascript or jQuery
我正在嘗試為我的頁面編寫一個js腳本:
有可能嗎?
這是我現在使用的腳本,允許我從主頁轉到first-url。
從first-url我再次單擊后退按鈕,它返回到主頁,然后再次單擊它返回到第一個URL,依此類推。
!function () {
{history.pushState({}, "", "#");
onpopstate = function (e) {
location.replace("https://www.first-url.com")
}
}
}();
任何幫助請添加第二個網址和第三個網址?
試試這些
$(window).on('popstate', function(event) {
window.location.href = 'https://www.first-url.com';
});
if(window.location.href == 'https://www.first-url.com') {
$(window).on('popstate', function(event) {
window.location.href = 'https://www.second-url.com';
});
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.