標籤:nbsp jquer static cdn baidu 習慣 src utf-8 safari
做網站活動頁面的時候,要為每個活動產生一個二維碼,雖然簡單,但還是習慣記錄下來。
jquery.qrcode.min.js是js的一個庫,主流的瀏覽器都支援:IE6~10, Chrome, Firefox, Safari, Opera, Mobile Safari, Android, Windows Mobile
方法: qrcode(),
參數:
text:要編碼的字串地址
width:定義的寬度
height:定義的高度
background:背景色
foreground:前景色彩
<!doctype html><html><head><meta charset="utf-8" /><title>產生二維碼</title><script type=‘text/javascript‘ src=‘http://cdn.staticfile.org/jquery/2.1.1/jquery.min.js‘></script><script type="text/javascript" src="http://cdn.staticfile.org/jquery.qrcode/1.0/jquery.qrcode.min.js"></script></head><body><div id="qrcode"></div></body><script>$("#qrcode").qrcode({width:64,height:64,text:"https://www.baidu.com/"})</script></html>
用qrcode.js產生二維碼,預設是canvas畫的
<!doctype html><html><head><meta charset="utf-8" /><title>產生二維碼</title><script type="text/javascript" src="qrcode.js"></script></head><body><div id="qrcode"></div></body><script>new QRCode(document.getElementById("qrcode"),"https://www.baidu.com/")</script></html>
為網頁產生二維碼(jquery.qrcode.min.js)