超碰中文网,91久久精品日日躁夜夜躁欧美,一区二区三区精品道,一区二区国产在线观看,亚洲精品中文字幕乱码一区二区,天天看片高清影视在线观看,久久99精品久久久久蜜桃,久久成人影视

VPS參考測(cè)評(píng)推薦
專注分享VPS主機(jī)優(yōu)惠信息
衡天云優(yōu)惠活動(dòng)
熱網(wǎng)互聯(lián)2026年促銷活動(dòng)
hostkvm優(yōu)惠促銷活動(dòng)
zji優(yōu)惠促銷活動(dòng)
QQGNET優(yōu)惠促銷活動(dòng)
QQGNET優(yōu)惠促銷活動(dòng)

使用js實(shí)現(xiàn)微信分享功能的示例代碼(使用js實(shí)現(xiàn)微信分享功能的示例代碼是什么)

主機(jī)參考:VPS測(cè)評(píng)參考推薦/專注分享VPS服務(wù)器優(yōu)惠信息!若您是商家可以在本站進(jìn)行投稿,查看詳情!此外我們還提供軟文收錄、PayPal代付、廣告贊助等服務(wù),查看詳情!
我們發(fā)布的部分優(yōu)惠活動(dòng)文章可能存在時(shí)效性,購(gòu)買時(shí)建議在本站搜索商家名稱可查看相關(guān)文章充分了解該商家!若非中文頁面可使用Edge瀏覽器同步翻譯!PayPal代付/收錄合作

本文主要介紹js在微信上分享好友鏈接的實(shí)現(xiàn),對(duì)學(xué)習(xí)ASP.NET編程技術(shù)有一定的幫助。感興趣的朋友可以參考一下。

通常,當(dāng)你想通過微信與朋友分享一個(gè)頁面時(shí),顯示的標(biāo)題和描述并不是你想要的。我自己查了一些資料,原來是js控制的。顯示效果如下:

標(biāo)題、描述和共享圖片都由js控制。Js代碼如下

& lt腳本& gtvar data for weixin = { appId:& quot;",MsgImg:& quot;Christmas/2010 12189457639 . gif & quot;,//顯示圖片TLImg:“Christmas/201012189457639 . gif & quot;,//顯示圖片URL:“Christmas/6 . html?stra=!u738B!u4F1F & quot,//跳轉(zhuǎn)地址標(biāo)題:“我把我的思念和祝福送給你,祝大家圣誕快樂”,//標(biāo)題內(nèi)容desc:“我把我的思念和祝福送給你,祝大家圣誕快樂”,//Description fake id:“& quot;,回調(diào):function(){ } };(function(){ var onBridgeReady = function(){ weixinsbridge . on(& amp;#39;菜單:共享:appmessage & amp#39;,function(argv){ weixinsbridge . invoke(& amp;#39;sendAppMessage & amp#39;,{ & quotappid & quot:dataForWeixin.appIdimg _ url & quot:dataForWeixin。MsgImgimg _ width & quot:& quot120 & quot,& quotimg _ height & quot:& quot120 & quot,& quot鏈接& quot:dataForWeixin.urldesc & quot;:dataForWeixin.desc,& quot標(biāo)題& quot:dataForWeixin.title },function(RES){(data forweixin . callback);});});weixinsbrbridge . on(& amp;#39;菜單:分享:時(shí)間線和。#39;,function(argv){(dataforweixin . callback)();weixinsbridge . invoke(& amp;#39;分享時(shí)間表。#39;,{ & quotimg _ url & quot:dataForWeixin。TLImg,& quotimg _ width & quot:& quot120 & quot,& quotimg _ height & quot:& quot120 & quot,& quot鏈接& quot:dataForWeixin.urldesc & quot;:dataForWeixin.desc,& quot標(biāo)題& quot:dataForWeixin.title },function(RES){ });});weixinsbrbridge . on(& amp;#39;菜單:分享:微博& amp#39;,function(argv){ weixinsbridge . invoke(& amp;#39;分享微博。#39;,{ & quot內(nèi)容& quot:dataForWeixin.titleurl & quot:dataForWeixin.url },function(RES){(data forweixin . callback);});});weixinsbrbridge . on(& amp;#39;菜單:分享:facebook & amp#39;,function(argv){(dataforweixin . callback)();weixinsbridge . invoke(& amp;#39;共享B&amp。#39;,{ & quotimg _ url & quot:dataForWeixin。TLImg,& quotimg _ width & quot:& quot120 & quot,& quotimg _ height & quot:& quot120 & quot,& quot鏈接& quot:dataForWeixin.urldesc & quot;:dataForWeixin.desc,& quot標(biāo)題& quot:dataForWeixin.title },function(RES){ });});};if(document . addevent listener){ document . addevent listener(& amp;#39;微信公眾號(hào)。#39;,onBridgeReady,false);} else if(document . attach event){ document . attach event(& amp;#39;微信公眾號(hào)。#39;,onBridgeReady);document . attach event(& amp;#39;onWeixinJSBridgeReady & amp#39;,onBridgeReady);} })();& lt/script & gt;

另一個(gè)微信分享js代碼:

/**!*微信內(nèi)置瀏覽器的Javascript API,功能包括* * 1、分享到微信朋友圈* 2、分享到微信好友* 3、分享到騰訊微博* 4、新增分享界面,包括好友、好友和微博的分享(iOS版)* 5、隱藏/顯示右上角菜單項(xiàng)* 6、隱藏/顯示底部瀏覽器工具欄* 7、獲取當(dāng)前網(wǎng)絡(luò)狀態(tài)* 8、調(diào)用微信客戶端的圖片播放組件* 9、關(guān)閉公眾平臺(tái)網(wǎng)頁*/var微信API;/* * *要在微信朋友圈分享的信息* @ param { Object } data * @p-config {String}公眾平臺(tái)appId(服務(wù)號(hào)可用)* @p-config {String} imgUrl圖片地址* @ P-config { String }鏈接地址* @p-config {String} desc描述分享的標(biāo)題* @ P-config { String } title * * @ param { Object }回調(diào)相關(guān)回調(diào)方法* @ P-config { Boolean } async ready方法是否需要異步執(zhí)行,默認(rèn)為false * @ P-config {function}您也可以取消* @ P-配置{功能}取消(對(duì)應(yīng))為空* @ P-配置{功能}失?。▽?duì)應(yīng))失敗* @ P-配置{功能}確認(rèn)(對(duì)應(yīng))成功* @ P-配置{功能}。無論成功或失敗都將執(zhí)行的所有(resp)回調(diào)*/function weixinsharetimeline(data,callbacks){ callbacks = callbacks | | { };var share timeline = function(the data){ weixinsbridge . invoke(& amp;#39;分享時(shí)間表。#39;,{ & quotappid & quot:theData.appId?thedata . appid:& amp;#39;& amp#39;,& quotimg _ url & quot:theData.imgUrl,& quot鏈接& quot:Data.linkdesc & quot;:theData.title標(biāo)題& quot:theData.desc,//注意這里要分享的內(nèi)容是desc“img _ width & quot;:& quot640 & quot,& quotimg _ height & quot:& quot640 & quot},function(resp){ switch(resp . err _ msg){//share _ timeline:取消用戶取消案例&;#39;取消& amp#39;:回調(diào)。取消和& amp回調(diào)。取消(resp);打破;// share_timeline:確認(rèn)發(fā)送成功。#39;確認(rèn)& amp#39;:案例& amp#39;分享時(shí)間線:ok & amp#39;:回調(diào)。確認(rèn)& amp& amp回調(diào)。確認(rèn)(響應(yīng));打破;// share_timeline:發(fā)送失敗案例失敗&;#39;失敗與時(shí)間線。#39;:默認(rèn)值:callbacks.fail & amp& amp回調(diào)。失?。╮esp);打破;}//回調(diào)。all &;& amp回調(diào)。all(resp);});};weixinsbrbridge . on(& amp;#39;菜單:分享:時(shí)間線和。#39;,function(argv){ if(callbacks . async & amp;& amp回調(diào)。就緒){ window【& quot;_ wx _ loadedCb _ & quot】= callbacks.dataLoaded ||新函數(shù)();if(窗口【& quot_ wx _ loadedCb _ & quot].toString()。index of(& quot;_ wx _ loadedCb _ & quot)& gt0){ window【& quot;_ wx _ loadedCb _ & quot】=新函數(shù)();} callbacks . data loaded = function(new data){ window【& quot;_ wx _ loadedCb _ & quot】(new data);share timeline(new data);};//然后ready回調(diào)。ready& amp回調(diào)。就緒(argv);} else {//就緒狀態(tài)回調(diào)。ready& amp回調(diào)。就緒(argv);shareTimeline(數(shù)據(jù));} });}/* * *要分享的信息發(fā)送給微信好友* @ param { Object } data * @p-config {String}公眾平臺(tái)appId(可用服務(wù)號(hào))* @p-config {String} imgUrl圖片地址* @ P-config { String }鏈接地址* @p-config {String} desc描述分享的標(biāo)題* @ P-config { String } title * * @ param { Object }回調(diào)相關(guān)回調(diào)方法* @p-config {Boolean}異步就緒方法是否需要異步執(zhí)行,默認(rèn)為false * @ P-config { Boolean您也可以取消* @ P-配置{功能}取消(對(duì)應(yīng))為空* @ P-配置{功能}失敗(對(duì)應(yīng))失敗* @ P-配置{功能}確認(rèn)(對(duì)應(yīng))成功* @ P-配置{功能}。all(resp)Callback */Function weixisendappmessage(data,callbacks){ callbacks = callbacks | | { };var sendAppMessage = function(the data){ weixinsbridge . invoke(& amp;#39;sendAppMessage & amp#39;,{ & quotappid & quot:theData.appId?thedata . appid:& amp;#39;& amp#39;,& quotimg _ url & quot:theData.imgUrl,& quot鏈接& quot:Data.linkdesc & quot;:theData.desc標(biāo)題& quot:theData.titleimg _ width & quot:& quot640 & quot,& quotimg _ height & quot:& quot640 & quot},function(resp){ switch(resp . err _ msg){//send _ app _ msg:取消用戶取消案例&;#39;發(fā)送應(yīng)用程序消息:取消& amp#39;:回調(diào)。取消和& amp回調(diào)。取消(resp);打破;// send_app_msg:確認(rèn)發(fā)送成功。#39;確認(rèn)& amp#39;:案例& amp#39;發(fā)送應(yīng)用程序消息:好的。#39;:回調(diào)。確認(rèn)& amp& amp回調(diào)。確認(rèn)(響應(yīng));打破;// send_app_msg:fail發(fā)送失敗案例&;#39;失敗& amp#39;:默認(rèn)值:callbacks.fail & amp& amp回調(diào)。失?。╮esp);打破;}//回調(diào)。all &;& amp回調(diào)。all(resp);});};weixinsbrbridge . on(& amp;#39;菜單:共享:appmessage & amp#39;,function(argv){ if(callbacks . async & amp;& amp回調(diào)。就緒){ window【& quot;_ wx _ loadedCb _ & quot】= callbacks.dataLoaded ||新函數(shù)();if(窗口【& quot_ wx _ loadedCb _ & quot].toString()。index of(& quot;_ wx _ loadedCb _ & quot)& gt0){ window【& quot;_ wx _ loadedCb _ & quot】=新函數(shù)();} callbacks . data loaded = function(new data){ window【& quot;_ wx _ loadedCb _ & quot】(new data);sendAppMessage(new data);};//然后ready回調(diào)。ready& amp回調(diào)。就緒(argv);} else {//就緒狀態(tài)回調(diào)。ready& amp回調(diào)。就緒(argv);sendAppMessage(數(shù)據(jù));} });}/* *要分享到騰訊微博的信息* @ param { Object } data * @ P-config { String }鏈接地址* @p-config {String} desc描述* * @param {Object}回調(diào)相關(guān)回調(diào)方法*是否需要異步執(zhí)行@p-config {Boolean} async ready方法,默認(rèn)為false * @ P-config { function } ready(argv)status * @ P-config { function } data loaded(數(shù)據(jù))數(shù)據(jù),在數(shù)據(jù)加載后調(diào)用。當(dāng)異步為真時(shí)很有用,您還可以取消* @ P-配置{功能}取消(響應(yīng))為空* @ P-配置{功能}失?。憫?yīng))失敗* @ P-配置{功能}確認(rèn)(響應(yīng))成功* @ P-配置{功能}。all(resp)callback */function weixinsharewebo(data,callbacks){ callbacks = callbacks | | { };var share Weibo = function(the data){ weixinsbridge . invoke(& amp;#39;分享微博。#39;,{ & quot內(nèi)容& quot:theData.descurl & quot:the data.link},function(resp){ switch(resp . err _ msg){//share _ Weibo:取消用戶取消案例&;#39;分享微博:取消& amp#39;:回調(diào)。取消和& amp回調(diào)。取消(resp);打破;// share_weibo:確認(rèn)發(fā)送成功。#39;分享_微博:確認(rèn)& amp#39;:案例& amp#39;分享_微博:ok & amp#39;:回調(diào)。確認(rèn)& amp& amp回調(diào)。確認(rèn)(響應(yīng));打破;// share_weibo:發(fā)送失敗案例失敗&;#39;分享_微博:失敗& amp#39;:默認(rèn)值:callbacks.fail & amp& amp回調(diào)。失敗(resp);打破;}//回調(diào)。all &;& amp回調(diào)。all(resp);});};weixinsbrbridge . on(& amp;#39;菜單:分享:微博& amp#39;,function(argv){ if(callbacks . async & amp;& amp回調(diào)。就緒){ window【& quot;_ wx _ loadedCb _ & quot】= callbacks.dataLoaded ||新函數(shù)();if(窗口【& quot_ wx _ loadedCb _ & quot].toString()。index of(& quot;_ wx _ loadedCb _ & quot)& gt0){ window【& quot;_ wx _ loadedCb _ & quot】=新函數(shù)();} callbacks . data loaded = function(new data){ window【& quot;_ wx _ loadedCb _ & quot】(new data);share Weibo(new data);};//然后ready回調(diào)。ready& amp回調(diào)。就緒(argv);} else {//就緒狀態(tài)回調(diào)。ready& amp回調(diào)。就緒(argv);shareWeibo(數(shù)據(jù));} });}/* * *新增分享界面* @param {Object}要分享的數(shù)據(jù)信息* @p-config {String}公共平臺(tái)的appId(服務(wù)號(hào)可用)* @p-config {String} imgUrl圖片地址* @p-config {String}鏈接地址* @p-config {String} desc描述分享的標(biāo)題* @ P-config { String } title * * @ param { Object }回調(diào)相關(guān)回調(diào)方法* @p-config {Boolean}是否需要異步執(zhí)行async ready方法,默認(rèn)為false * @ P-config { function } ready(ready您還可以取消* @ P-配置{function}取消(resp,shareto)* @ P-配置{function}失?。╮esp,shareto)失敗* @ P-配置{function}確認(rèn)(resp,ShareTo)成功* @ P-配置{function}所有(resp,ShareTo)回調(diào),無論成功與否都將執(zhí)行*/function weixingeneralshare(data,callbacks){ callbacks =回調(diào)||{var general share = function(general,the data){//如果分享到朋友圈,則需要交換標(biāo)題和desc If(general。共享到= = &;#39;時(shí)間線& amp#39;){ var title = theData.titlethedata . title = thedata . desc | | title;theData.desc = title}//與general . general Share({“appid & quot;:theData.appId?thedata . appid:& amp;#39;& amp#39;,& quotimg _ url & quot:theData.imgUrl,& quot鏈接& quot:Data.linkdesc & quot;:theData.desc標(biāo)題& quot:theData.titleimg _ width & quot:& quot640 & quot,& quotimg _ height & quot:& quot640 & quot},function(resp){ switch(resp . err _ msg){//general _ share:取消用戶取消case &;#39;取消& amp#39;:回調(diào)。取消和& ampcallbacks . cancel(resp,general . shareto);打破;// general_share:確認(rèn)發(fā)送成功。#39;確認(rèn)& amp#39;:案例& amp#39;通用共享:ok & amp#39;:回調(diào)。確認(rèn)& amp& ampcallbacks . confirm(resp,general . shareto);打破;// general_share:發(fā)送失敗案例失敗&;#39;失敗& amp#39;:默認(rèn)值:callbacks.fail & amp& ampcallbacks . fail(resp,general . shareto);打破;}//回調(diào)。all &;& ampcallbacks . all(resp,general . shareto);});};weixinsbrbridge . on(& amp;#39;菜單:常規(guī):共享& amp#39;,function(general){ if(callbacks . async & amp;& amp回調(diào)。就緒){ window【& quot;_ wx _ loadedCb _ & quot】= callbacks.dataLoaded ||新函數(shù)();if(窗口【& quot_ wx _ loadedCb _ & quot].toString()。index of(& quot;_ wx _ loadedCb _ & quot)& gt0){ window【& quot;_ wx _ loadedCb _ & quot】=新函數(shù)();} callbacks . data loaded = function(new data){ window【& quot;_ wx _ loadedCb _ & quot】(new data);generalShare(通用,new data);};//然后ready回調(diào)。ready& ampcallbacks . ready(general,general . shareto);} else {//就緒狀態(tài)回調(diào)。ready& ampcallbacks . ready(general,general . shareto);generalShare(通用,數(shù)據(jù));} });}/* * *注意(此功能只是臨時(shí)添加的,由于權(quán)限限制無法使用。如果你的站點(diǎn)部署在*。QQ。com下,也許是可行的* @ param { String } appWeixinId微信微信官方賬號(hào)ID * @param {Object} callbacks回調(diào)方法* @p-config {Function} fail(resp)失敗* @ P-config { Function }。confirm(resp)成功*/function添加聯(lián)系人(appweixinid,callbacks){ callbacks = callbacks | | { };weixinsbridge . invoke(& quot;添加聯(lián)系人& quot,{ web type:& quot;1 & quot,用戶名:appWeixinId },函數(shù)(resp){ var success =!resp.err _ msg | | & quot添加聯(lián)系人:好的= = resp.err _ msg | | & quot添加聯(lián)系人:已添加& quot= = resp.err _ msgif(success){ callbacks . success & amp;& amp回調(diào)。成功(resp);} else { callbacks.fail & amp& amp回調(diào)。失?。╮esp);} })}/* *調(diào)出微信原生的圖片播放組件。*此處必須強(qiáng)有力地檢測(cè)到參數(shù)。如果參數(shù)非法,將直接導(dǎo)致微信客戶端當(dāng)前播放的圖像地址崩潰* * @ param { String } curSrc * @ param { Array } src list圖像地址列表*/函數(shù)圖像預(yù)覽(curSrc,src list){ if(!curSrc ||!src list | | src list . length = = 0){ return;} weixinsbridge . invoke(& amp;#39;圖像預(yù)覽& amp#39;,{ & amp#39;當(dāng)前和未來。#39;:curSrc & amp;#39;urls & amp#39;:srcList });}/* * *顯示button */function showoptionmenu(){ weixinsbridge . call(&;#39;showOptionMenu & amp#39;);}/* * *隱藏網(wǎng)頁右上角的按鈕*/Function Hide option Menu(){ weixinsbridge . call(&;#39;隱藏選項(xiàng)菜單& amp#39;);}/* * *顯示底部工具欄*/Function show toolbar(){ weixinsbridge . call(&;#39;顯示工具欄& amp#39;);}/* * *隱藏底部工具欄*/Function Hide toolbar(){ weixinsbridge . call(&;#39;隱藏工具欄。#39;);}/* * *返回以下類型:* * network_type:wifi wifi網(wǎng)絡(luò)* network_type:edge非wifi,包括3G/2G * network_type:無法斷開網(wǎng)絡(luò)連接* network_type:wwan 2g或3g * *用法:* weixiAPI。getnetworktype(function(網(wǎng)絡(luò)類型){ * * });* * @ param callback */function getNetworkType(callback){ if(callback & amp;& amp回調(diào)類型= = & amp#39;功能與應(yīng)用。#39;){ weixinsbridge . invoke(& amp;#39;getNetworkType & amp#39;,{},function(e){//Get e . err _ msg此處包含所有網(wǎng)絡(luò)類型回調(diào)(e . err _ msg);});}}/* *關(guān)閉當(dāng)前微信公眾平臺(tái)頁面*/functionclosewindow(){ weixinsbridge . call(“closeWindow & quot;);}/* * *當(dāng)頁面被加載時(shí),它將被執(zhí)行。用法:*胃脘痛。ready(function(API){ *//從這里看,只有API是WeixinApi * });* @ param ready callback */function wxJsBridgeReady(ready callback){ if(ready callback & amp;& amptypeof readyCallback = = & amp#39;功能與應(yīng)用。#39;){ var Api = thisvar wxReadyFunc = function(){ readyCallback(Api);};如果(窗口的類型。WeixinJSBridge = = & quot未定義& quot){ if(document . addevent listener){ document . addevent listener(& amp;#39;微信公眾號(hào)。#39;,wxReadyFunc,false);} else if(document . attach event){ document . attach event(& amp;#39;微信公眾號(hào)。#39;,wxReadyFunc);document . attach event(& amp;#39;onWeixinJSBridgeReady & amp#39;,wxReadyFunc);} } else { wxReadyFunc();} } }返回{ version:& quot;2.0 & quot,ready :wxJsBridgeReady,shareToTimeline:weixinShareTimeline,shareToWeibo:weixinsharewibo,shareToFriend:weixinSendAppMessage,general share:weixinGeneralShare,addContact :addContact,showOptionMenu :showOptionMenu,hideOptionMenu,showToolbar :showToolbar,hideotbar:getNetworkType:getNetworkType,imagePreview :imagePreview,close window:close window };})();

這幾篇文章你可能也喜歡:

本文由主機(jī)參考刊發(fā),轉(zhuǎn)載請(qǐng)注明:使用js實(shí)現(xiàn)微信分享功能的示例代碼(使用js實(shí)現(xiàn)微信分享功能的示例代碼是什么) http://m.k2270.com/113201.html

【騰訊云】領(lǐng)8888元采購(gòu)禮包,搶爆款云服務(wù)器 每月 9元起,個(gè)人開發(fā)者加享折上折!
打賞
轉(zhuǎn)載請(qǐng)注明原文鏈接:主機(jī)參考 » 使用js實(shí)現(xiàn)微信分享功能的示例代碼(使用js實(shí)現(xiàn)微信分享功能的示例代碼是什么)
主機(jī)參考僅做資料收集,不對(duì)商家任何信息及交易做信用擔(dān)保,購(gòu)買前請(qǐng)注意風(fēng)險(xiǎn),有交易糾紛請(qǐng)自行解決!請(qǐng)查閱:特別聲明

評(píng)論 搶沙發(fā)

評(píng)論前必須登錄!