This time I will show you how to operate the WebSQL database in H5. What are the precautions for H5 to operate the WebSQL database? The following is a practical case, let's take a look.
HTML code:
nbsp;html> <meta> <title>列车时刻表查询</title> <meta> <link> <script></script> <script></script> <script></script> <p> </p><p> </p><h1 id="列车时刻表查询">列车时刻表查询</h1> <p> </p><p>请给我留言</p>
姓名: | 留言: |
---|---|
收藏成功,暂且不做处理!.
请点击右上角有个关闭按钮
提示: 你也可以点击弹窗的外部区域来关闭弹窗。
JS code:
/** * HTML5 操作本地WebSQL数据库 * 作者:汪政 * 时间:2017/08/26 15:03:19 */ var datatable = null; var db = openDatabase("MyData", "", "My Database", 1024 * 100); //初始化函数方法 function init() { datatable = document.getElementById("datatable"); showAllData(); } //首先移除乱七八糟的东西 function removeAllData() { for(var i = datatable.childNodes.length - 1; i >= 0; i--) { datatable.removeChild(datatable.childNodes[i]); } var tr = document.createElement("tr"); var th1 = document.createElement("th"); var th2 = document.createElement("th"); var th3 = document.createElement("th"); th1.innerHTML = "姓名"; th2.innerHTML = "留言"; th3.innerHTML = "时间"; tr.appendChild(th1); tr.appendChild(th2); tr.appendChild(th3); datatable.appendChild(tr); } //显示WebSQL中的数据 function showData(row) { var tr = document.createElement("tr"); var td1 = document.createElement("td"); td1.innerHTML = row.name; var td2 = document.createElement("td"); td2.innerHTML = row.message; var td3 = document.createElement("td"); var t = new Date(); t.setTime(row.time); td3.innerHTML = t.toLocaleDateString() + " " + t.toLocaleTimeString(); tr.appendChild(td1); tr.appendChild(td2); tr.appendChild(td3); datatable.appendChild(tr); } //显示所有的数据 function showAllData() { db.transaction(function(tx) { tx.executeSql("CREATE TABLE IF NOT EXISTS MsgData(name TEXT,message TEXT,time INTEGER)", []); tx.executeSql("SELECT * FROM MsgData", [], function(tx, rs) { removeAllData(); for(var i = 0; i I believe you have mastered it after reading the case in this article Method, for more exciting information, please pay attention to other related articles on the php Chinese website! <p></p>Recommended reading: <p></p><p style="text-align: left;">How to use the prefix data-attribute and dataset<a href="http://www.php.cn/html5-tutorial-390175.html" target="_blank"></a><br></p><p style="text-align: left;">Drag event editor implements drag and drop upload Picture effect<a href="http://www.php.cn/html5-tutorial-390172.html" target="_blank"></a><br></p>
The above is the detailed content of How to operate WebSQL database with H5. For more information, please follow other related articles on the PHP Chinese website!

Advanced tips for H5 include: 1. Use complex graphics to draw, 2. Use WebWorkers to improve performance, 3. Enhance user experience through WebStorage, 4. Implement responsive design, 5. Use WebRTC to achieve real-time communication, 6. Perform performance optimization and best practices. These tips help developers build more dynamic, interactive and efficient web applications.

H5 (HTML5) will improve web content and design through new elements and APIs. 1) H5 enhances semantic tagging and multimedia support. 2) It introduces Canvas and SVG, enriching web design. 3) H5 works by extending HTML functionality through new tags and APIs. 4) Basic usage includes creating graphics using it, and advanced usage involves WebStorageAPI. 5) Developers need to pay attention to browser compatibility and performance optimization.

H5 brings a number of new functions and capabilities, greatly improving the interactivity and development efficiency of web pages. 1. Semantic tags such as enhance SEO. 2. Multimedia support simplifies audio and video playback through and tags. 3. Canvas drawing provides dynamic graphics drawing tools. 4. Local storage simplifies data storage through localStorage and sessionStorage. 5. The geolocation API facilitates the development of location-based services.

HTML5 brings five key improvements: 1. Semantic tags improve code clarity and SEO effects; 2. Multimedia support simplifies video and audio embedding; 3. Form enhancement simplifies verification; 4. Offline and local storage improves user experience; 5. Canvas and graphics functions enhance the visualization of web pages.

The core features of HTML5 include semantic tags, multimedia support, offline storage and local storage, and form enhancement. 1. Semantic tags such as, etc. to improve code readability and SEO effect. 2. Simplify multimedia embedding with labels. 3. Offline storage and local storage such as ApplicationCache and LocalStorage support network-free operation and data storage. 4. Form enhancement introduces new input types and verification properties to simplify processing and verification.

H5 provides a variety of new features and functions, greatly enhancing the capabilities of front-end development. 1. Multimedia support: embed media through and elements, no plug-ins are required. 2. Canvas: Use elements to dynamically render 2D graphics and animations. 3. Local storage: implement persistent data storage through localStorage and sessionStorage to improve user experience.

H5 and HTML5 are different concepts: HTML5 is a version of HTML, containing new elements and APIs; H5 is a mobile application development framework based on HTML5. HTML5 parses and renders code through the browser, while H5 applications need to run containers and interact with native code through JavaScript.

Key elements of HTML5 include,,,,,, etc., which are used to build modern web pages. 1. Define the head content, 2. Used to navigate the link, 3. Represent the content of independent articles, 4. Organize the page content, 5. Display the sidebar content, 6. Define the footer, these elements enhance the structure and functionality of the web page.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Zend Studio 13.0.1
Powerful PHP integrated development environment

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

SublimeText3 Chinese version
Chinese version, very easy to use

SublimeText3 Linux new version
SublimeText3 Linux latest version

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.
