html5學習canvas基本使用:div在js前面;localStorage儲存根據瀏覽器在不同的位置;應用程式緩衝;placeholder 屬性提供一種提示(hint),描述輸入欄位所期待的值。

來源:互聯網
上載者:User

 <body><canvas id="myCanvas" width="300px;" height="200px"style="border:1px solid #00ff00;"></canvas><script  type="text/javascript">var c=document.getElementById("myCanvas");var cxt=c.getContext("2d");cxt.moveTo(0,0);cxt.lineTo(150,60);cxt.lineTo(10,60);cxt.stroke();</script><hr><br><canvas id="myCanvas2" width="300px;" height="200px"style="border:1px solid #00ff00;"></canvas><script  type="text/javascript">var c=document.getElementById("myCanvas2");var cxt=c.getContext("2d");cxt.fillStyle="#ff0000";cxt.beginPath();cxt.arc(70,18,15,0,Math.PI*2,true);//畫弧context.arc(x, y, radius, startAngle, endAngle, anticlockwises)cxt.closePath();cxt.fill();</script>  </body>
localstorage基本使用方法如下:預設存數的是字串類型
if(localStorage.pageCount){localStorage.pageCount=Number(localStorage.pageCount)+1;//pageCount自訂的}else{localStorage.pageCount=1;}document.write("visit"+localStorage.pageCount+"time(s)");</script>
 這樣的話,你的本地磁碟中就會有個資料庫存下了這個資料。我無法接受資料寫到了我的本地磁碟而我找不到它的確切位置,於是通過尋找發現:Chrome 的儲存方式是以sqlite的資料庫檔案形式儲存。存在C:\Users\Username\AppData\Local\Google\Chrome\User Data\Default\Local Storage 中,雖然尾碼名是.localstorege 但是實際上就是sqlite的資料庫檔案,可以用sqlite開啟,並看到其中的資料

HTML5 引入了應用程式緩衝,這意味著 web 應用可進行緩衝,並可在沒有網際網路串連時進行訪問。

應用程式緩衝為應用帶來三個優勢:

  • 離線瀏覽 - 使用者可在應用離線時使用它們
  • 速度 - 已緩衝資源載入得更快
  • 減少伺服器負載 - 瀏覽器將只從伺服器下載更新過或更改過的資源。 <html manifest="http://www.w3school.com.cn/example/html5/html5_html_manifest.html.appcache"><!--demo.apache--><body><p>請開啟<a href="http://www.w3school.com.cn/example/html5/html5_html_manifest.html" target="_blank">這個頁面</a>,然後離線瀏覽,重新載入頁面。頁面中的指令碼和映像依然可用。</p>
每個指定了 manifest 的頁面在使用者對其訪問時都會被緩衝。如果未指定 manifest 屬性,則頁面不會被緩衝(除非在 manifest 檔案中直接指定了該頁面)
請注意,manifest 檔案需要配置正確的 MIME-type,即 "text/cache-manifest"。必須在 網頁伺服器上進行配置。

manifest 檔案可分為三個部分:

  • CACHE MANIFEST - 在此標題下列出的檔案將在首次下載後進行緩衝
  • NETWORK - 在此標題下列出的檔案需要與伺服器的串連,且不會被緩衝
  • FALLBACK - 在此標題下列出的檔案規定當頁面無法訪問時的回退頁面(比如 404 頁面)
CACHE MANIFEST# 2012-02-21 v1.0.0/theme.css/logo.gif/main.jsNETWORK:login.aspFALLBACK:/html5/ /404.html
<input type="search" name="user_search"  placeholder="Search W3School" />

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.