HTML5 and Local Storage.

Slides:



Advertisements
Similar presentations
Cookies, Sessions. Server Side Includes You can insert the content of one file into another file before the server executes it, with the require() function.
Advertisements

Cascading Style Sheets
Today CSS HTML A project.
Principles of Web Design 5 th Edition Chapter Nine Site Navigation.
Web Development & Design Foundations with XHTML Chapter 7 Key Concepts.
CIS 1310 – HTML & CSS 6 Layout. CIS 1310 – HTML & CSS Learning Outcomes  Describe & Apply the CSS Box Model  Configure Float with CSS  Designate Positioning.
CSW131 Steven Battilana 1 CSW 131 – Chapter 5 (More) Advanced CSS Prepared by Prof. B. for use with Teach Yourself Visually Web Design by Ron Huddleston,
Web Pages and Style Sheets Bert Wachsmuth. HTML versus XHTML XHTML is a stricter version of HTML: HTML + stricter rules = XHTML. XHTML Rule violations:
กระบวนวิชา CSS. What is CSS? CSS stands for Cascading Style Sheets Styles define how to display HTML elements Styles were added to HTML 4.0 to.
ADVANCED CSS William Neely CEO, Piecewise.com. CSS FONTS AND TEXT CSS ‣ Line-height allows to indicate the amount of space between lines; allows for equal.
Web Design with Cascading Style Sheet Lan Vu. Overview Introduction to CSS Designing CSS Using Visual Studio to create CSS Using template for web design.
CSS (Cascading Style Sheets): How the web is styled Create Rules that specify how the content of an HTML Element should appear. CSS controls how your web.
TUTORIAL 8: Enhancing a Web Site with Advanced CSS
Chapter 9 Collecting Data with Forms. A form on a web page consists of form objects such as text boxes or radio buttons into which users type information.
Working with Cascading Style Sheets. Introducing Cascading Style Sheets Style sheets are files or forms that describe the layout and appearance of a document.
Tutorial 7 Creating Forms. Objectives Session 7.1 – Create an HTML form – Insert fields for text – Add labels for form elements – Create radio buttons.
 Word doc for you to download › Link at the beginning of class › 10 Questions › Answers to be added inline  Post to Sakai when completed › No resubmits.
Introduction to HTML. What is HTML?  Hyper Text Markup Language  Not a programming language but a markup language  Used for presentation and layout.
How the Web Works Building a Website – Lesson 1. How People Access the Web Browsers People access websites using software called a web browser. To view.
JavaScript: Objects 1 © by Pearson Education, Inc. All Rights Reserved.
 Add one element at a time  If it doesn’t do what you want, › Delete it › DON’T just keep piling on more items.
111 State Management Beginning ASP.NET in C# and VB Chapter 4 Pages
CSS (Cascading Style Sheets). CSS CSS – Cascading Style Sheets – Cascade because of the way CSS rules can stack on top of each other. Allows you to add.
Internet & World Wide Web How to Program, 5/e 1. 2.
CSS.
4.01 How Web Pages Work.
>> Form Data Validation in JavaScript
DHTML.
Cascading Style Sheets Layout
4.01 How Web Pages Work.
Google fonts CSS box model
The Box Model in CSS Web Design – Sec 4-8
CSS Layouts: Grouping Elements
Unit 3 - Review.
ASP.NET Web Controls.
Introduction to Web programming
Box model.
Intro to CSS CS 1150 Fall 2016.
Web Systems & Technologies
Introduction to web design discussing which languages is used for website designing
The Internet 10/25/11 XHTML Tables
Cascading Style Sheets
CSS.
IS333: MULTI-TIER APPLICATION DEVELOPMENT
Essentials of Web Pages
Styles and the Box Model
TOPICS Chrome Dev Tools Process for Building a Static Website
Fixed Positioning.
CSS Box Model.
Chapter 27 WWW and HTTP.
MORE Cascading Style Sheets (The Positioning Model)
Software Engineering for Internet Applications
CSS and Box Model.
DynamicHTML Cascading Style Sheet Internet Technology.
Lesson Objectives Aims You should know about: – Web Technologies
Cascading Style Sheets
HTML5 and Local Storage.
Static and Dynamic Web Pages
Cascading Style Sheets™ (CSS)
DynamicHTML Cascading Style Sheet Internet Technology.
Building ASP.NET Applications
Training & Development
Floating and Positioning
The Internet 10/27/11 XHTML Forms
Multipage Sites.
4.01 How Web Pages Work.
Web Client Side Technologies Raneem Qaddoura
Web Programming and Design
Introduction to Cascading Style Sheets (CSS)
Cascading Style Sheets™ (CSS)
Presentation transcript:

HTML5 and Local Storage

Topics HTML5 Storage Key-value pairs localStorage Object

Cookies Before HTML5 Websites could store only small amounts of text-based information on a user’s computer using cookies.

How Cookies Worked A website might use a cookie to record user preferences or other information that it can retrieve during the client’s subsequent visits. When a user visits a website, the browser locates any cookies written by that website and sends them to the server.

Developing with Cookies Cookies may be accessed only by the web server and scripts of the website from which the cookies originated . The browser sends these cookies with every request to the server.

Drawbacks with Cookies Cookies have a number of problems associated with them. Offline access is not often performed very well. memory is limited.

Is there a solution to Cookies? HTML5 Storage

HTML5 Storage HTML5 Storage is also known as: Local Storage   HTML5 Storage is also known as: Local Storage Web Storage DOM Storage

How does HTML5 Storage work?   HTML5 Storage allows web applications to store persistent data locally in web browsers. Persistent data stored does not expire with a session. If you browse away from the site that saved the data or close the browser, you will notice that the data is still there when you open it again or check for it locally. The storage option is supported by all modern browsers, even mobile ones.

HTML5 Client-Side Storage Overview There are several ways to store data on a user’s computer: Web Storage: Single file that uses key-values. Indexed Database: Key-value Indexed table. Web SQL: Structured Database.

Web Storage Options Web storage is always local. Values can be set and retrieved even when the browser has been closed and re-opened. Web storage can also be used for sessions. A storage session can be cleared when a window closes.

Examining Website Storage It is easy to find out if a website uses Storage. Google Chrome Developer Tools Examine Storage in Applications.

Working with HTML5 Web Storage The mechanism for storage is key-value pairs. Web applications can use the window object’s localStorage property to store up to several megabytes of key-value-pair string data on the user’s computer. localStorage can access that data across browsing sessions.

HTML5 Web Storage vs Cookies Unlike cookies, data in the localStorage object is not sent to the web server with each request. Websites often use both cookies and localStorage.

HTML5 Web Storage TIPS Each website domain has a separate localStorage object. All the pages from a given domain share one localStorage object. Typically 5BM are reserved for each localStorage object. If web storage is full, the browser can ask the user if more space should be allocated.

Key Value Pairs A key value pair is a key with a corresponding value. The key and value are both strings. For example Key: “address” Value: “1200 E Colton Ave”

localStorage Object Methods length() to get the number of key-value pairs stored in local storage. key(i) to collect the key at index i. getItem() and setItem() to set and get a key item. removeItem() to remove a key-value pair from local storage

Practice

Task 1: Determine the Divisions <!DOCTYPE html> <html> <head> <title>To Do List</title> <link rel = "stylesheet“ type = "text/css" href = "css/style.css"> <script src = "js/todo.js"></script> </head> <body onload='initialize()'> </body> </html>

Inside <body> <div> <h1>My TO-DO App</h1>   <p> <input id = "todoTag" type = "text" placeholder = "Add a TO-DO Item"> <button onclick="saveSearch();"> Save </button> <button onclick="clearAllItems();"> Clear All Items </button> </p> <h1>TO-DO Items</h1> <div id = "searchList"></div>

CSS Formatting Use nth-child to style even/odd elements. Use span to create elements on a line with other elements.

CSS p { margin: 0px; } #welcomeMessage { margin-bottom: 10px; font-weight: bold; input[type = "text"] { width: 350px; input[type = "button"]{ width: 100px;   /* list item styles */ span { margin-left: 10px; display: inline-block; li { list-style-type: none; width: 500px; li:first-child { border-top: 1px solid grey; li:nth-child(even) { background-color: lightyellow; border-bottom: 1px solid grey; li:nth-child(odd) { background-color: lightblue; CSS

Write the JavaScript