Recommended:

  • phpclasses.org
  • jsclasses.org
  • jsmag.com
  • siteapps.com
  • View our reviews on Hot Scripts
  • JS Tutorial
  • scripts.com
  • securesignup.com




Recent Comments

Powered by Disqus




Back to articles

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

Back to method list

Method namenew qrcode(config)
DescriptionCreate QRcode instance with specified configuration
Input parameters

json config - Json structure with configuration properties:

  • int size - size of image in pixels
  • ec_level - Error correction level. Possible values : L, M, Q, H. (default: L - lowest)
  • int margin - white margin around QRcode in qrcode rows or columns

Create QRcode with text

Back to method list

Method nametext(id, text)
DescriptionCreate 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

Back to method list

Method namelink(id, link)
DescriptionCreate 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

Back to method list

Method namebookmark(id, title, link)
DescriptionCreate 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

Back to method list

Method namesms(id, phone, text)
DescriptionCreate 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

Back to method list

Method namephone_number(id, phone)
DescriptionCreate 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

Back to method list

Method namecontact_info(id, name, address, phone, email)
DescriptionCreate 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

Back to method list

Method nameemail(id, email, subject, message)
DescriptionCreate 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

Back to method list

Method namegeo(id, lat, lon, height)
DescriptionCreate 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

Back to method list

Method namewifi(id, type, ssid, pass)
DescriptionCreate 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

Like our script? Rate it at PHP > Hot Scripts

Scripts.com
RATE ME!

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

blog comments powered by Disqus