简体   繁体   中英

Saving URLs to local storage

So this was a dumb problem and all you need to do is use some local storage. Why I ever asked this, I have no idea.

I believe you want to use HTML5 localStorage to accomplish this.

https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage

You'll be able to storage your presets into localStorage, then load them all for the user.

you can simply keep your url in local storage all you need to do is

var url=location.href;
localStorage.setItem("url",url);
function loadOldUrl(){
location.href=localStorage.getItem("url");
}
//when button clicked
document.querySelector("#myButton").addEventListener("click",loadUrl);

i think this code will do the trick for you you can read about location more here and the local storage here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM