追萬軟件公司-專業從事企業軟件定制、系統軟件開發、用戶管理系統、進銷存系統等軟件開發

如何通過jquery生成二維碼

隨著移動互聯網普及,催生了二維碼廣泛的應用,生活中隨處可見都是二維碼,而我們在系統開發中,也經常經使用到二維碼,也需要根據不同的實際情況為用戶生成不同的二維碼,追萬網絡技術人員給大家分享一個通過的二維碼生成技術,只需要簡單的調用一個函數即可生成。

function toUtf8(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;    
}

function showewm(locations,str){//locations顯示位置,str生成的內容
    jQuery("#"+locations).qrcode({render:"table",width:"150",height:"150",text:toUtf8(str)/*將內容進行轉碼*/});
}

這兩個函數已做備注,只需要根據實際使用情況來修改即可。

另外還有兩個核心的包含文件,自行下載即可

JQUERY生成二維碼.zip

最新文章

熱門文章

欧美中国韩国日本多水385,国产精品亚亚洲欧关中字幕,αv天堂aⅴ影音先锋手机版,清纯唯美五月丁香俺也去,小说区图片区自拍视频在线,xfplay中文字幕在线资源,俺去啦官网无码免费视频,久久中文字幕乱码久久午夜,日韩AV噜噜噜在线观看