HTML5網(wǎng)頁(yè)如何調(diào)用瀏覽器APP的微信分享功能的代碼,這段代碼從網(wǎng)上找的,還沒(méi)有經(jīng)過(guò)實(shí)際的測(cè)試,有興趣的朋友可以參考一下。
if (/AppleWebKit.*Mobile/i.test(navigator.userAgent) || (/MIDP|SymbianOS|NOKIA|SAMSUNG|LG|NEC|TCL|Alcatel|BIRD|DBTEL|Dopod|PHILIPS|HAIER|LENOVO|MOT-|Nokia|SonyEricsson|SIE-|Amoi|ZTE/.test(navigator.userAgent))) {
if (window.location.href.indexOf("?mobile") < 0) {
try {
//判斷是手機(jī)端訪問(wèn)
if (/Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)) {
//判斷是UC瀏覽器
if (typeof (ucweb) != "undefined") {
//微信好友
$("#btnShareFirend").unbind();
$("#btnShareFirend").bind("click", function () {
var Browser = new Object();
Browser.ios = /iphone/.test(Browser.userAgent); //判斷ios系統(tǒng)
var title = document.title;
var img = "";
var url = location.href;
if (Browser.ios) {
ucbrowser.web_share(title, img, url, 'kWeixin', '', '', '');
} else {
ucweb.startRequest("shell.page_share", [title, img, url, 'WechatFriends', '', '', '']);
};
});
//微信朋友圈
$("#btnWeixinShare").unbind();
$("#btnWeixinShare").bind("click", function () {
var Browser = new Object();
Browser.ios = /iphone/.test(Browser.userAgent); //判斷ios系統(tǒng)
var title = document.title;
var img = "";
var url = location.href;
if (Browser.ios) {
ucbrowser.web_share(title, img, url, 'kWeixinFriend', '', '', '');
} else {
ucweb.startRequest("shell.page_share", [title, img, url, 'WechatTimeline', '', '', '']);
};
});
}
}
} catch (e) { }
}
}