欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

基于JavaScript實(shí)現(xiàn)生成名片、鏈接等二維碼

 更新時(shí)間:2015年09月20日 10:18:04   投稿:mrr  
本文使用javascript技術(shù)實(shí)現(xiàn)生成名片、鏈接等二維碼的代碼,代碼簡(jiǎn)單易懂并附有注釋,需要的朋友可以參考下本文

廢話不多說(shuō),直接貼代碼了,具體內(nèi)容如下;

<div id = "qrcodeid"></div> //生成的二維碼放在此 div 中
<script type="text/javascript" src="js/jquery.qrcode.min.js"></script>//引入qrcode.js(到https://github.com/jeromeetienne/jquery-qrcode 下載 )
<script>
function utf16to8(str) { //解決中文亂碼
  var out, i, len, c; 
  out = ""; 
  len = str.length; 
  for(i = 0; i < len; i++) { 
  c = str.charCodeAt(i); 
  if ((c >= 0x0001) && (c <= 0x007F)) { 
    out += str.charAt(i); 
  } else if (c > 0x07FF) { 
    out += String.fromCharCode(0xE0 | ((c >> 12) & 0x0F)); 
    out += String.fromCharCode(0x80 | ((c >> 6) & 0x3F)); 
    out += String.fromCharCode(0x80 | ((c >> 0) & 0x3F)); 
  } else { 
    out += String.fromCharCode(0xC0 | ((c >> 6) & 0x1F)); 
    out += String.fromCharCode(0x80 | ((c >> 0) & 0x3F)); 
  } 
  } 
  return out; 
} 
</script>
<script>//此處生成名片二維碼(如要生成普通鏈接二維碼 則 “text”參數(shù)值 直接替換成普通鏈接即可)
var the_text = "BEGIN:VCARD \r\nFN:姓名 \r\nTEL;CELL,VOICE:15000000000 \r\nTITLE:職稱 \r\nORG:公司(組織) \r\nEMAIL;INTERNET,HOME:123@qq.com \r\nADR;WORK,POSTAL:地球中國(guó)山東... \r\nURL:http://leerd.cn \r\nEND:VCARD";
the_text = utf16to8(the_text);
//alert(the_text);
jQuery('#qrcodeid').qrcode({
width:140,
height:140,
render:"canvas", //設(shè)置渲染方式 table canvas
typeNumber : -1,  //計(jì)算模式 
correctLevel  : 0,//糾錯(cuò)等級(jí) 
background   : "#ffffff",//背景顏色 
foreground   : "#000000",//前景顏色 
text:the_text
}); 
</script>

以上內(nèi)容就是本文的全部?jī)?nèi)容,希望大家喜歡。

相關(guān)文章

最新評(píng)論