简体   繁体   English

将URL保存到本地存储

[英]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. 我相信您想使用HTML5 localStorage来完成此任务。

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

You'll be able to storage your presets into localStorage, then load them all for the user. 您将能够将预设存储到localStorage中,然后将其全部加载给用户。

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 我觉得这个代码将会为你做的伎俩,你可以更了解位置在这里和本地存储在这里

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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