I am trying to make every link or page with a dedicated reading page. For example, I have a lot of pages when visiting one page, storage is made, but the problem comes when he visits another page. He does not start again. He goes to the last id. I want to make each page with its own address.
<script>
window.onunload = function() {
var url_string = window.location.href ;
var url = new URL(url_string);
var value = document.getElementById("pageNumber").value;
localStorage.setItem("last", value , url_string );
var c = url.searchParams.get("c");
};
window.onload = function(){
var url_string = window.location.href ;
var url = new URL(url_string);
var c = url.searchParams.get("c");
var value = localStorage.getItem("last" , url_string);
if(value) {
document.getElementById("pageNumber").value = value;
window.location.href = "#" + value;
}
};
How do I do that and make each link have private storage
Another example https://hululkitaab.com/test/cct.html
https://hululkitaab.com/test/fcvcb.html
If you visited the first link and went to page number 20
When you visit the following link, it will return you to number 20 I do not want this any suggestions
what about this:
const pageName = "myPageName";
localStorage.setItem(pageName + "last", value);