Get the App
SLTechnology News&Howtos  ›  Development  › 

How to develop a simple website list program with Web Storage

Shulou Source: shulou.com Published: 2022-06-01 05:11:21 09月24日 Update

This article mainly explains "how to develop a simple website list program with Web Storage". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to develop a simple website list program with Web Storage.

The website listing program implements the following functions:

You can enter the website name and URL, and save it to localStorage under the name of key

Find the URL according to the name of the website

List all currently saved websites

The following code is used to save and find data:

Save () and find () methods

/ / Save data

Function save () {

Var siteurl = document.getElementById ("siteurl") .value

Var sitename = document.getElementById ("sitename") .value

LocalStorage.setItem (sitename, siteurl)

Alert ("added successfully")

}

/ / find data

Function find () {

Var search_site = document.getElementById ("search_site") .value

Var sitename = localStorage.getItem (search_site)

Var find_result = document.getElementById ("find_result")

The URL of find_ result [XSS _ clean] = search_site + "is:" + sitename

}

The complete example is shown as follows:

Example

Website name (key):

Network address (value):

At this point, I believe you have a deeper understanding of "how to develop a simple website list program with Web Storage". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Tags: Website website name program development data URL content example method learning input utility depth success code interest function practicality practicality simple operation Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn MariaDB Shulou Technology Shulou Tech Info Linux