current position:Home>HTML enters jump for the first time and does not jump for the second time.

HTML enters jump for the first time and does not jump for the second time.

2022-02-02 22:44:37 CSDN Q & A

The user enters the current page for the first time 1.html. Auto jump to 2.html

2.html It is set to automatically jump to 1.html

This time is equivalent to the user returning to 1.html. It's an infinite cycle .

How can we make a cycle . Just start fighting 1 Jump to 2.2 Jump to 1 Don't jump .

Then it will cycle only after refresh .

Mainly 1.html How does it say . Static .




Refer to the answer 1:

Scheme 1 , Add a logo ( Easy to operate ):

One 、1.html Jump 2.html after ,2.html Jump back and add a logo , for example :

location.href=1.html?hasGoto=true

Two 、1.html If there is a parameter hasGoto, No longer jump

Option two : By writing cookie perhaps localstorage( The advantage is implicit )




Refer to the answer 2:



Refer to the answer 3:

Can you add a judgment , Create a value , The default value is true, Take the value with you when you jump , Complete the jump and change the value to false, Judge whether this value is true, If so, that's the first time I came in , You jump , If it's the first time, jump , No, don't jump




Refer to the answer 4:



Refer to the answer 5:

stay 1.html Set a sign inside , Change state after jump , Then jump according to the status




Refer to the answer 6:



Refer to the answer 7:

Listen for page fallback Events
window.on('popstate', function(){
// to do
})




Refer to the answer 8:



Refer to the answer 9:

2 Lou Zhengjie




Refer to the answer 10:

copyright notice
author[CSDN Q & A],Please bring the original link to reprint, thank you.
https://en.primo.wiki/2022/02/202202022244355751.html

Random recommended