function shareToQQ() { var url = "https://connect.qq.com/widget/shareqq/index.html"; var shareUrl = "http://www.baidu.com"; var title = "分享標題"; var summary = "分享顯示的內容簡介"; var pics = "圖片地址"; var width = "32"; var height = "32"; var allUrl = url + "?url=" + encodeURIComponent(shareUrl) + "&title=" + title + "&summary=" + summary + "&pics=" + pics + "&width=" + width + "&height=" + height; openNewWin({ url : allUrl, target : "_blank", }); }
var url = "https://connect.qq.com/widget/shareqq/index.html";//qq分享的urlhtml
var shareUrl = "http://www.baidu.com";//這個url是點擊分享內容跳轉的連接jquery
var title = "分享標題";//分享後顯示的標題web
var summary = "分享顯示的內容簡介";//顯示在qq分享界面的簡介內容canvas
var pics = "圖片地址";//分享到QQ顯示的圖片瀏覽器
var width = "32";微信
var height = "32";url
由於jQuery有相應的js生成二維碼 ,首先咱們先下載jQuery.qrcode.min.js jQuery.qrcode調試
接下來就是使用js生成二維碼圖片code
首先咱們應該新建一個div 用來顯示二維碼,並把div的id設置成qrcodeidhtm
<div id="qrcodeid"></div>
function createQrcode(){ //此處生成名片二維碼\ var url = "http://www.baidu.com"; var the_text = utf16to8(url); //alert(the_text); $('#qrcodeid').qrcode({ width : 140, height : 140, render : "canvas", //設置渲染方式 table canvas typeNumber : -1, //計算模式 correctLevel : 0,//糾錯等級 background : "#ffffff",//背景顏色 foreground : "#000000",//前景顏色 text : the_text, }); } 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; }
接下咱們就是調節一下二維碼的位置就能夠了。 其實還有不少其餘的分享,我就不一一介紹了。感興趣的你們就到網上搜索一下。