HTML&javaSkcript&CSS&jQuery&ajax(11)

來源:互聯網
上載者:User

標籤:let   delete   jquery   基礎   分享   lin   插入   html基礎   html5   

1、localStorage 沒有 時間的限制資料存放區, sessionStorage 針對一個session的儲存,首先檢查瀏覽器是否支援對這兩個的儲存,

     ifI(type(Storage)!=="undefined"){

          // 支援}else{

                        不支援}

      localStorage對資料存放區沒有時間的限制,eg、

       <div id="result"></div>

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

                 lLocalStorage.sitename="菜鳥";

                     document.getElementById("result").innerHTML=“網站名”+"localStorage.setname;}

                                   else{

                     document.getElementById("result").innerHTML="瀏覽器不支援"}</script>

2、計算 <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="比支援"}

                      }</script>

3、web SQL操作

   openDatabase 使用資料庫  transaction 控制資料庫   execute Sql    資料庫查詢

  開啟資料庫     var  db=openDatabase("mydb", ‘1.0‘, ‘test DB‘,2*1024*1024)分別是資料庫名稱, 版本號碼  描述文本  資料庫大小

                                   db.transaction(function(tx){ tx.executeSql(‘CREATE Table if  not exists LoGS (id unique,log)‘);});

          刪除資料記錄  db.transaction(function(tx){

                                    tx.excuteSql(‘delete from logs where id=1‘)})

        更新資料   db.transaction(function(tx){

                                        tx.excuteSql(‘Update logs set log=\‘www.w3cschool\‘ where id=2‘);})

4、啟用應用程式緩衝  <!DOCTYPE HTML>

                               <html manifest="demo.appcache">   </html>

5、接收 Servert -sent事件通知

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

    source.onmessage=function(event){

              doucnemt.getElementById("result").innerHTML++evnt.data+"<br>";}

  檢測server-Sent事件支援    if(type(EventSource)!=="undefined"){

                                 //瀏覽器支援}else{

                              //瀏覽器不支援  Server-sent}

6、WebSocket是HTML5單個TCP連結上的全雙工系統通訊協議, WebSocketAPI中。瀏覽器和伺服器只需要做一次握手工作,然後瀏覽器和伺服器之間就形成一條快速通道,兩者之間就直接可以同資料, 介質是 JavaScript像伺服器發送建立WebSocket的連結請求,當擷取WEbSocket 連結之後 通過send()方法像伺服器發送資料。並通過onmessage事件來接受伺服器返回的資料。

 

一、Html部分

HTML基礎:

   1、HTML標題(heading)t通過<h1><h6>標籤定義,

        eg:<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>SueKay</title>
<body>
<h1>it‘s my sister </h1>
<p>it‘s your sister</p.html
>
</body>
</html>

    2、段落標<p>,</p>  ,<hr >這個標籤用於對段落的分割,段落順序倒著寫<p><bdo dir="rtl">這段文字倒著顯示</bdo></p>

刪除效果<p>My favorite color is <del>blue</del>  <ins>red</ins></p>

     <! DOCTYPE html >

<html>

<head>it‘s my notebook</head>

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

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

</html>

另外HTML的注釋,<!--it‘s   notesiad-->,插入段落之間的水平線使用標籤<hr/>,在一個段落中實現回行,直接鍵入標籤<br>

 3、HTML連結<a href="http://www.baidu.com">it‘s a link</a>

 4、HTML映像連結 <img src=“img/log/png ” width=“23” height=“23”>

5、文字格式設定化:對<body>中的字型進行設定<b> 粗體 <i>斜體顯示。<sub></sub>下標 <sup></sup>上標,

                           <pre></pre>標籤的使用保留原來文本的輸入樣式

                         

<code></code>電腦輸出標籤樣式,<var></var >電腦變數。

<address> written by <a href="maitl:[email protected]">Jon Doe</a></address>

 

HTML&javaSkcript&CSS&jQuery&ajax(11)

相關文章

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.