diff --git a/JavaScript/Advance/Web API/web-storage API/images/js-logo.png b/JavaScript/Advance/Web API/web-storage API/images/js-logo.png new file mode 100644 index 0000000..4637ac9 Binary files /dev/null and b/JavaScript/Advance/Web API/web-storage API/images/js-logo.png differ diff --git a/JavaScript/Advance/Web API/web-storage API/index.html b/JavaScript/Advance/Web API/web-storage API/index.html new file mode 100644 index 0000000..89fb533 --- /dev/null +++ b/JavaScript/Advance/Web API/web-storage API/index.html @@ -0,0 +1,26 @@ + + + + + + + + web-storage API + + + +

Web Storage API

+ +

+ +

localStorage

+ +

+ + +

sessionStorage

+ +

+ + + \ No newline at end of file diff --git a/JavaScript/Advance/Web API/web-storage API/script.js b/JavaScript/Advance/Web API/web-storage API/script.js new file mode 100644 index 0000000..4ed8cd5 --- /dev/null +++ b/JavaScript/Advance/Web API/web-storage API/script.js @@ -0,0 +1,34 @@ +/* Storage API are used for storing data files + There are two main types of storing data in web page + 1. localStorage() --> used for storing data permenantly + 2. sessionStorage() --> used for storing data for short period of time +*/ +let textOne = document.getElementById('textOne'); + +function DisplayOne() { + textOne.innerHTML = ` +

Storage API are of Two Types

+

1. localStorage: ()

+

Used for Storing Data Permanently

+

2. sessionStorage()

+

Used for Storing Data Short Time

+ ` +} + +// Example One localStorage() + +let textTwo = document.getElementById('textTwo'); + +function DisplayTwo() { + localStorage.setItem("name", "Azhar"); + textTwo.innerHTML = localStorage.getItem("name"); +} + +// Example Two sessionStorage() + +let textThree = document.getElementById('textThree'); + +function DisplayThree() { + sessionStorage.setItem("name", "Musharraf"); + textThree.innerHTML = sessionStorage.getItem("name"); +} \ No newline at end of file