index.js
function getScript(cfg) {

  var script = function(cfg) {
    $('#J_Qrcode').qrcode({
      'render': 'canvas',
      'size': cfg.size || 150,
      'color': '#3a3',
      'text': cfg.text
    });

    var canvas = $('#J_Qrcode canvas')[0];
    // here is the most important part because if you dont replace you will get a DOM 18 exception.
    var imageData = canvas.toDataURL('image/png').replace('image/png', 'image/octet-stream');

    endCallback(imageData);
  };

  return '(' + script.toString() + ')(' + JSON.stringify(cfg) + ');';
}
function getScript(cfg) {

  var script = function(cfg) {
    $('#J_Qrcode').qrcode({
      'render': 'canvas',
      'size': cfg.size || 150,
      'color': '#3a3',
      'text': cfg.text
    });

    var canvas = $('#J_Qrcode canvas')[0];
    // here is the most important part because if you dont replace you will get a DOM 18 exception.
    var imageData = canvas.toDataURL('image/png').replace('image/png', 'image/octet-stream');

    endCallback(imageData);
  };

  return '(' + script.toString() + ')(' + JSON.stringify(cfg) + ');';
}
function getScript ( cfg ) { var script = function ( cfg ) { $ ( '#J_Qrcode' ) . qrcode ( { 'render' : 'canvas' , 'size' : cfg . size || 150 , 'color' : '#3a3' , 'text' : cfg . text } ) ; var canvas = $ ( '#J_Qrcode canvas' ) [ 0 ] ; // here is the most important part because if you dont replace you will get a DOM 18 exception. var imageData = canvas . toDataURL ( 'image/png' ) . replace ( 'image/png' , 'image/octet-stream' ) ; endCallback ( imageData ) ; } ; return '(' + script . toString ( ) + ')(' + JSON . stringify ( cfg ) + ');' ; }
get the script to generate canvas in the browser
get the script to generate canvas in the browser