After I again how to withdraw the current page from the COOKIE jumps over previous page link?
Click physical keys on his mobile phone because I want to be returned by the function, and add a meta page source to stop the record of the page, so the document. The referrer unable to get back to record, so think of use cookies to make, but when to begin to get found too difficult, I don't know how to start, also searched a lot of information, without access to relevant information, so have to come to consult, still hope BBS bosses can give help ah, thank you very much,
Below is that mobile phones bring back the JS code,
PushHistory ();
Window. The addEventListener (" popstate ", function (e) {
If (document. The referrer==' ') {
Window. The location="without the referrer will jump to specify page address";
} else {
Window. The history. The go (1);
}
}, false);
The function pushHistory () {
Var state={
Title: "title",
Url: "#"
};
Window. The history. PushState (state, "title", "#");
}
CodePudding user response:
Use cookie is bad, should use the sessionStorage
<script type="text/javascript">
Var historyArr=JSON. Parse (sessionStorage. HistoryArr | | "[]");
The console. The log (historyArr);
If (historyArr [0]!=location. Href) {
HistoryArr. Unshift (location. Href);
SessionStorage. HistoryArr=JSON. Stringify (historyArr);
}
The function historyBack () {
If (historyArr. Length<2) return;
HistoryArr. Shift ();
SessionStorage. HistoryArr=JSON. Stringify (historyArr);
The location. The href=https://bbs.csdn.net/topics/historyArr [0];
}
</script>
CodePudding user response: