store user favorite color in background to page

WEB STORAGE API

Today I am going to discuss the most useful topic of HTML5 API (Web storage API). In HTML5, web storage API provides an important role in web design. In this Content, I’ll provide Overview of web storage API with an Example.

HTML5 API

HTML5 API is an important feature of HTML. In this Topic one of the most important features is web storage there are some features of HTML5 API is given below

  1. MEDIA API
  2. TEXT TRACK API
  3. DRAG AND DROP
  4. WEB STORAGE API
  5. USER INTERACTION
  6. MIME TYPE and PROTOCOL HANDLER REGISTRATION
  7. API in THE WHATWG SPECIFICATION
  8. HTML5 “buzzword” APIs
  9. DEMOS and Browser support

WEB STORAGE API

Web storage APIs is the most crucial component of HTML5. It Holds some of the important features of Design. WEB storage API is used to store the data in the client system. It Helps in share the data between one page to multiple pages. It works completely on the client system. The stores’ data of the client system is not accessible from the server code. It Will save the data Permanently in your system Hard disc.

IMPLEMENTATION OF WEB STORAGE

Web storage is implemented with the following Objects. Those Objects are given below.

  • localStorage
  • sessionStorage

These Objects comes with following Methods.

  • setItem(key,values)
  • getItem(key)
  • removeItem(key)
  • clear()

<!–Create a webpage to store user favorite color in local storage and apply as the background color to page–>
<html>
  <head></head>
  <body id=”b1″ onload=”f2()”>
     <h3>Javascript Programming</h3>
     <hr>
     Select favorite color:
     <input type=”color” id=”t1″/>
     <input type=”button” value=”Update” onclick=”f1()”>
     <input type=”button” value=”Reset” onclick=”f3()”>
     <hr><hr>
     <a href=”sessionStorage_color2.html”> Go to the next page</a>
     <script>
function f1()
{
var obj1=document.getElementById(“t1”);
var obj2=document.getElementById(“b1”);
localStorage.setItem(“x”,obj1.value);
obj2.style.backgroundColor=obj1.value;
}
//page load event
function f2()
{
var obj2=document.getElementById(“b1”);
var str=localStorage.getItem(“x”);
obj2.style.backgroundColor=str;

}
//reset buton Click
function f3()
{
localStorage.removeItem(“x”);
var obj2=document.getElementById(“b1”);
obj2.style.backgroundColor=”White”;
}
    </script>

</body>
</html> 

OUTPUT

WEB STORAGE API


When you choose and Update color the Background color is changed, and the status is stored on your computer hard disc. and when you reload the page after reload the page comes with background changed color.


WEB STORAGE API

 

Next page code

 <html>
  <head>
  </head>
<body id=”b1″ onload=”f2()”>
<h3>JavaScript Programming</h3>
<hr/>
<h1>This Is Page</h1>
<script>
function f2()
{
var obj=document.getElementById(“b1”);
var str=localStorage.getItem(“x”);
obj.style.backgroundColor=str;
}
</script>
</body>
</html>

2nd Page also conatain same color from 1st page

VISIT MY 2nd WEBSITE

 

Please visit this page again for more DESIGNS

👉 Agar Post Accha Lga to Share Kro Be aur Comment thoko.

 

 

 

Introduction of Macro in System Software

Introduction of Macro in System Software

A macro is a unit of specification of program generation through expansion. A macro consists of a name set of formal parameters and a body of code. A macro name is an abbreviation which stands for some related lines of code. Macro is useful for the following purpose. To simply and reduce the amour of …

0 comments
TOP 5 EARPHONES in 2019

TOP 5 EARPHONES IN 2019

TOP 5 EARPHONES IN 2019 TOP 5 EARPHONES IN 2019 If you are finding the  TOP 5 EARPHONES FOR YOU then I will help you to suggest the  TOP 5 EARPHONES IN 2019 and I know you also like my suggestion because of first research all details About These All Earphones. then I am going …

0 comments
WEB STORAGE API

store user favorite color in background to page

Today I am going to discuss the most useful topic of HTML5 API (Web storage API). In HTML5, web storage API provides an important role in web design. In this Content, I’ll provide Overview of web storage API with an Example. HTML5 API HTML5 API is an important feature of HTML. In this Topic one of …

0 comments
Dialog Box

Preview of Dialog Tag

The <dialog> element originally entered the HTML5 scene as a way to markup conversations, but it was cut from the spec back in 2009. However, now it’s back, and it has a brand new role. The new <dialog> element makes it easy for developers to create popup dialogs and modals for their web applications. Before …

0 comments
Why Python is a Scripting Language.

Why Python is a Scripting Language.

Why Python is a Scripting Language? Why Python is a Scripting Language?, This topics is always to complex. Actually, Pyhon Supports Programming or scripting both features. with the views of its usage, Python is called scripting language. Python is a programming and scripting language. Everybody can develop any software with the use of python programming. …

0 comments
Script

What is Script in Computer Programming?

Scripts: In Computer Programming Scripts are the lists many commands, Programs, and The sequence of instructions. which is executable by any other Program or scripting Engines. They are usually put in text documents with many instructions using any scripting language. What is Script? In Computer Programming World. Scripts are the lists many commands, Programs, and The sequence …

0 comments
How To Remove Pattern On Android

How To Remove Pattern On Android Without Factory Reseting

How To Remove Pattern On Android Without Factory Resetting How To Remove Pattern On Android: Now these Days this term is very useful for that man who wants to go access from anyone Android phone, and I have a trick for those users. Please follow the rules which are given below and Share this Article. …

0 comments

Moviescouch || Download HD Movies

75Moviescouch:- Moviescouch is a movie Downloading website. Now, these Days movie is the best popular platform for entertainment. In this article, I’ve full describe in details How to Download movie from Moviescouch website. So please follow given steps to download any movie from Moviescouch. How to Download any movie from Moviescouch. Here we’ll guide you …

0 comments
Difference between Information security and cybersecurity.

Difference between Information security and cybersecurity.

  Hey, All my crazy friends who want to learn cybersecurity. I’ve also some information on this topic Difference between Information security and Cybersecurity. The reason I’ve selected this topic today Because as it says, this is one of the most popular topics in the Market. I’ve been there since people keep his information secure …

1 comment
macroprocessor

Overview of Macro-processor.

The macro processor is system software. It is actually a program which is a part of the assembler program. The macro processor is designed in passes. In the design of the macro processor. There are two important functions to be considered. They are given below. Saving the micro definition. Expanding the microcells. These functions are …

0 comments
Assembly Language

Overview of Assembly Language

Overview of Assembly Language An assembly language is any low-level language in which there is the very correspondence between the program’s statements and the architecture machine code instruction. Each assembly language is specific to particular computer architecture and some time to on the operating system. Advantage of assembly language:-  It is easier to correct errors …

0 comments