Using Google Charts to make QR Codes

Jul 13, 2010 javascript jquery misc-web
This post is more than 18 months old. Since technology changes too rapidly, this content may be out of date (but that's not always the case). Please remember to verify any technical or programming information with the current release.

Google Charts is my hero yet again. This time, I happened to notice that they have a chart in their API for QR Codes. Considering I was just searching google for a PHP class to do this, I was pretty ecstatic.

To implement, I made a quick line of jQuery to generate my QR Codes. Of course, I did this after the page loaded :) My goal was to generate a QR code for the page that the user is currently viewing. Pretty simple:

$("#qrImage").attr(
  'src', 
  'http://chart.apis.google.com/chart?chs=150x150&cht;=qr&chl;=' 
    + escape(window.location.href) 
    + '&choe;=UTF-8'
);

You can find all of the details and other parameters here: http://code.google.com/apis/chart/docs/gallery/qr_codes.html

Go to All Posts