12345678910111213141516171819202122232425 | <script type="text/javascript"> function QRCode(content, width, height){ // 預設寬高為 120x120 width = !!width ? width : 120 ; height = !!height ? height : 120; // 編碼 content = encodeURIComponent(content); return 'http://chart.apis.google.com/chart?cht=qr&chl=' + content + '&chs=' + width + 'x' + height; } window.onload = function(){ document.getElementById('qrcode').onclick = function(){ var msg = document.getElementById('content'); var imgSrc = QRCode(msg.innerHTML, 240, 240); msg.innerHTML = '<img src="' + imgSrc + '" alt="" />'; }; };</script> <body> <input type="button" value="QRCode" id="qrcode" /> <div id="content"> Google Chart API 是一組能讓使用者只透過 URL 傳遞參數就能快速產生各種圖表的 API。可產生的圖片類型包括線形圖、長條圖與圓餅圖,同時也能指定的每種圖片屬性,例如大小、色彩與標籤等。 </div></body> |