Generate QR codes using javascript
QR code class can be used to generate QR Code images using Google Chart API.
Currently the class can request the generation of QR codes for information snippets of types: bookmark, text, SMS message, phone number, contact information, e-mail message, geo-location, WIFI access.
Contents
Download
Example codes
<html> <head> </head> <body> <p>Link</p> <div id='qrcode_div'></div> <script src="./qrcode.js" type="text/javascript"></script> <script> var qr = new qrcode({ /*************************************** * Size of QRcode in pixels * As QRcode is a square, only one value is needed ****************************************/ size: 150, /*************************************** * Error correction level for damaged or misinterpretted codes * Lower - more data stored, but less errors could be corrected * High - less data can be stord, more information can be recovered * Possible types of error collection: * L - [Default] Allows recovery of up to 7% data loss * M - Allows recovery of up to 15% data loss * Q - Allows recovery of up to 25% data loss * H - Allows recovery of up to 30% data loss ****************************************/ ec_level: "L", /*************************************** * Margin - white space around QRcode in * QRcode columns and rows, no pixels ****************************************/ margin: 1 } ); //id of container, link qr.link("qrcode_div", "http://webcodingeasy.com/"); </script> </body> </html>
Examples in action
Example scripts provided with package in action:
Method list
- Constructor
- Create QRcode with text
- Create QRcode with link
- Create QRcode with bookmark
- Create QRcode with SMS
- Create QRcode with phone number
- Create QRcode with contact info
- Create QRcode with email message
- Create QRcode with geographical location
- Create QRcode with WiFi access
Constructor
| Method name | new qrcode(config) |
| Description | Create QRcode instance with specified configuration |
| Input parameters | json config - Json structure with configuration properties:
|
Create QRcode with text
| Method name | text(id, text) |
| Description | Create QRcode with UTF-8 encoded text |
| Input parameters | string id - ID of element where to display QR code string text - text which to encode in QRcode |
Create QRcode with link
| Method name | link(id, link) |
| Description | Create QRcode with link |
| Input parameters | string id - ID of element where to display QR code string link - URL which to encode in QRcode |
Create QRcode with bookmark
| Method name | bookmark(id, title, link) |
| Description | Create QRcode with bookmark |
| Input parameters | string id - ID of element where to display QR code string title - title of bookmark string title - URL of bookmark |
Create QRcode with SMS
| Method name | sms(id, phone, text) |
| Description | Create QRcode with sms |
| Input parameters | string id - ID of element where to display QR code string phone - Phone number, where to send SMS string text - SMS text |
Create QRcode with phone number
| Method name | phone_number(id, phone) |
| Description | Create QRcode with phone number |
| Input parameters | string id - ID of element where to display QR code string phone - phone number which to encode in QRcode |
Create QRcode with contact info
| Method name | contact_info(id, name, address, phone, email) |
| Description | Create QRcode with contact info |
| Input parameters | string id - ID of element where to display QR code string name - Firstname and Lastname of person string address - Address of person string phone - Phone number of person string email - Email address of person |
Create QRcode with email message
| Method name | email(id, email, subject, message) |
| Description | Create QRcode with email message |
| Input parameters | string id - ID of element where to display QR code string email - Email address where to send email string subject - Subject of email string message - Message of email |
Create QRcode with geographical location
| Method name | geo(id, lat, lon, height) |
| Description | Create QRcode with geographical location |
| Input parameters | string id - ID of element where to display QR code string lat - Latitude string lon - Longitude string height - Height from earth surface |
Create QRcode with WiFi access
| Method name | wifi(id, type, ssid, pass) |
| Description | Create QRcode with WiFi access |
| Input parameters | string id - ID of element where to display QR code string type - Authentication type string ssid - Identification of network,ssid string pass - Password of network |
Latest changes
None for now
Rate us
Try it out and Rate on JSclasses.org
Support
JS classes support forum or comments below
You may also be interested in:
Powered by BlogAlike.com










