Html&javaskcript&css&jquery&ajax (11)

Source: Internet
Author: User

1, Localstorage no time limit data storage, Sessionstorage for a session of storage, first check whether the browser supports the storage of these two,

IfI (Type (Storage)!== "undefined") {

Support}else{

Not supported}

Localstorage There is no time limit for data storage, eg,

<div id= "Result" ></div>

<script> IfI (typeof (Storage)!== "undefined") {

Llocalstorage.sitename= "rookie";

document.getElementById ("Result"). Innerhtml= "Site name" + "LOCALSTORAGE.SETNAME;}

else{

document.getElementById ("Result"). innerhtml= "Browser not supported"}</script>

2, calculate <div id= "Reult" ></div>

<script> function Clickcount () {

if (typeof (Storage) 1== "undefined") {

if (Localstorage.clickcount) {

Localstorage.clickcount=number (Localstorage.clickcount) +1;

}else{

Localstorage.clickcount=1;}

document.getElementById ("Result"). innerhtml= "Localstorage.localcount;

}else{

Doucment.getElement.ById ("Result"). Innerhtml= "than supported"}

}</script>

3. Web SQL operations

OpenDatabase using database transaction to control database execute SQL database queries

Open the database var db=opendatabase ("MyDB", ' 1.0 ', ' Test db ', 2*1024*1024) are the database name, the version number describes the text database size

Db.transaction (Function (TX) {tx.executesql (' CREATE Table if not exists LoGS (id unique,log) ');});

Delete data record db.transaction (function (TX) {

Tx.excutesql (' Delete from logs where id=1 ')})

Update Data db.transaction (function (TX) {

Tx.excutesql (' Update logs set log=\ ' www.w3cschool\ ' where id=2 ');})

4. Enable application cache <! DOCTYPE html>

5, receive Servert-sent event notification

var source=new EventSource ("demo-sse.php");

Source.onmessage=function (event) {

Doucnemt.getelementbyid ("Result"). innerhtml++evnt.data+ "<br>";}

Detect Server-sent Event Support if (type (EventSource)!== "undefined") {

Browser support}else{

Browser does not support server-sent}

6, WebSocket is the HTML5 single TCP link on the full-duplex communication protocol, WEBSOCKETAPI. The browser and server only need to do a handshake, and then the browser and the server form a fast channel between the two directly can be the same data, the media is JavaScript like the server sent to establish WebSocket link request, when the WebSocket link is obtained Send data like a server via the Send () method. The data returned by the server is accepted by the OnMessage event.

First, the HTML part

HTML Basics:

1, the HTML title (heading) t through the

eg:<! DOCTYPE html>
<meta charset= "Utf-8" >
<title>SueKay</title>
<body>
<p>it ' s your sister</p.html
>
</body>

2, paragraph mark <p>,</p>,

Remove effects <p>my favorite color is <del>blue</del> <ins>red</ins></p>

<! DOCTYPE HTML >

<body><p>it ' s your dog </p>

<p>it ' s second <br> paragraph</p><body>

In addition the comments of the HTML,<!--it's notesiad--> Insert the horizontal line between the paragraphs using the label

3. html link <a href= "http://www.baidu.com" >it ' s a link</a>

4. HTML Image link

5, text formatting: Set the font in <body> <b> bold <i> italic display. <sub></sub> Subscript <sup></sup> Superscript,

The use of <pre></pre> labels preserves the input style of the original text

<code></code> computer output label style, <var></var > Computer variable.

<address> written by <a href= "Maitl:[email protected]" >jon doe</a></address>

Html&javaskcript&css&jquery&ajax (11)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.