HTML 5 using Demo sample in Web SQL

Source: Internet
Author: User

Web SQL This is a mock database browser. You can use the JS operation SQL to complete the data read and write, but this thing is not many, now support the browser, and its specifications have been discontinued support. Looks like its foreground is not very bright.

Specifications: Http://www.w3.org/TR/webdatabase/#dom-sqltransaction-sync-executesql (now has stopped updating, the organization did not want to know the direction of development)

Supported browsers and version numbers:

Safari (3.2+)
Chrome (3.0+)
Opera (10.5+)

Pass through conventional offline applications use WebStorage, but WebStorage has a very large limitation, for example, storage space. Domain security mechanisms, and so on. There are not so many restrictions on Web SQL. It has more storage space (can define its own settings), cross-domain reading and writing, storage structure, such as freedom. And it is convenient to use SQL to read and write.

Demo Sample Code

<! DOCTYPE html>

, ?

,?) ', [Name, Message, Time],function (TX, RS) {//document.getelementbyid ("msg"). InnerHTML = "Save data successfully ! ";}, Function (TX, error) {alert (Error.source +":: "+ error.message); }); }); }//Save data Function SaveData () {var name = document.getElementById (' name '). Value; var memo = document.getElementById (' Memo '). Value; var time = new Date (). GetTime (); AddData (Name,memo,time); ShowAllData (); }//Delete table data function DeleteData () {Db.transaction (function (TX) {tx.executesql ("Delete from Msgdata", [],function (TX, RS) {//alert ("Data deleted successfully!"); }, Function (TX, error) {alert (Error.source + "::" + error.message); });}); ShowAllData ();} </script>


For Websql. Because of the broad rules of reading and writing, it is a very big security problem, cross-domain read, XSS attacks, SQL injection, etc. are very headache. So what kind of data can be stored and stored. Need to be considered carefully. The company has now stopped the update of the specification, may not be comfortable with the current specification design, and now the browser vendor support is not high, perhaps the development. is still unknown.


Copyright notice: This article blog original article. Blogs, without consent, may not be reproduced.

HTML 5 using Demo sample in Web SQL

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.