gpt4 book ai didi

javascript - 你如何从 localStorage 调用 url

转载 作者:行者123 更新时间:2023-11-30 05:58:03 25 4
gpt4 key购买 nike

<分区>

我想在设置页面上将 url 保存到 localStorage-。然后我需要一个超链接或一个按钮,点击后会转到该 url。尽量不使用 jquery。

<!doctype html>
<html>
<head>
<title>Local Storage URL</title>

<script type="text/javascript">
function save() {
var myURL = document.getElementById('url');
localStorage.setItem('url', myURL.value);
}

function load() {
var storedValue = localStorage.getItem('url');
if(storedValue) {
document.getElementById('url').value = storedValue;
}
}

</script>

</head>

<body onLoad="load()">
<input type="text" id="url" />
<input type="button" value="save" onclick="save()" />
<p>
<-- Here is where I am stuck below --><br>
<a href="('myUrl')">Link to localStorage Address</a>
</body>
</html>

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com