簡體   English   中英

javascript重定向后,后退按鈕無法正常工作

[英]back button not working after javascript redirect

我有一個嵌入隨機網站的小部件。 當用戶點擊時我調用服務器來更新發生的點擊,服務器返回重定向到正確的頁面。 問題是瀏覽器的后退按鈕不再有效。

我使用location.href進行重定向。

我嘗試了location.replace - 它保留了后退按鈕,但是它會在單擊小部件的頁面之前進入頁面(它將其替換為新頁面)。

報告到服務器后如何進行頁面切換並仍然允許后退按鈕工作?

您無法返回自動重定向的頁面。 這只是一個破損的按鈕和一個沮喪的用戶。

User goes to page A.
User clicks on link to page B.
Page B automatically redirects to page C with window.location.
User hits back button and momentarily goes back to page B.
Page B automatically redirects to page C with window.location.
User hits back button and momentarily goes back to page B.
Page B automatically redirects to page C with window.location.
User is sad.

顯然這不起作用。 它必須像這樣工作:

User goes to page A.
User clicks on link to page B.
Page B automatically redirects to page C with window.location.replace().
User hits back button and goes back to page A.
User is happy.

如果要使用后退按鈕,則必須使用window.location.replace()自動重定向。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM