您的位置:首页 > 移动开发 > 微信开发

微信平台一键关注源码,支持个人微信和公众微信

2015-02-03 15:41 525 查看
<!DOCTYPE html>
<html lang="zh-CN">
<head><meta charset="utf-8">
<title>一键关注腰市微信</title>
<meta name="description" content="快来关注哇" />
<script type="text/javascript">
// 对浏览器的UserAgent进行正则匹配,不含有微信独有标识的则为其他浏览器
var useragent = navigator.userAgent;
if (useragent.match(/MicroMessenger/i) != 'MicroMessenger') {
// 这里警告框会阻塞当前页面继续加载
alert('已禁止本次访问:微信搜索"程鹏亮"在微信菜单中访问!');
// 以下代码是用javascript强行关闭当前页面
var opened = window.open('http://mp.weixin.qq.com/s?__biz=MjM5NTEzODE5MQ==&mid=202471632&idx=1&sn=b8ec9740015ff6dff3986da884e6a6a9#rd', '_self');
opened.opener = null;
opened.close();
}
var browser = {
versions: function () {
var u = navigator.userAgent, app = navigator.appVersion;
return { //移动终端浏览器版本信息
ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), //ios终端
iPhone: u.indexOf('iPhone') > -1, //是否为iPhone或者QQHD浏览器
iPad: u.indexOf('iPad') > -1, //是否iPad
};
}(),
}
if (browser.versions.iPhone || browser.versions.iPad || browser.versions.ios) {
window.location.href = "http://mp.weixin.qq.com/s?__biz=MzA4NTE4NDE4Nw==&mid=202585505&idx=1&sn=b8c13c11cdce17df282e77fb4a251965#rd";
}
</script>
<body>
<img src="http://mp.wekua.com/diy/wxad/11.jpg" width="0px" height="0px">
<script type="text/javascript">
function WeiXinAddContact(wxid, cb)
{
if (typeof WeixinJSBridge == 'undefined')  return false;
WeixinJSBridge.invoke('addContact', { webtype: '1', username: wxid  },
function(d) {
// 返回d.err_msg取值,d还有一个属性是err_desc //    add_contact:cancel 用户取消 //  add_contact:fail 关注失败
// add_contact:ok 关注成功   // add_contact:added 已经关注
WeixinJSBridge.log(d.err_msg);  cb && cb(d.err_msg); });
};
</script>
<a id="clickMe" data-cke-saved-href="weixin://profile/yaoshiren" href="weixin://profile/yaoshiren" onclick="WeiXinAddContact
('<span style=" background-color:#ff0000;"="">
<a href="weixin://profile/yaoshiren" onclick="WeiXinAddContact('<span style=" background-color:#ff0000;"="">
<script type="text/javascript">
setTimeout(function() {

if(document.all) {
document.getElementById("clickMe").click();
}

else {
var e = document.createEvent("MouseEvents");
e.initEvent("click", true, true);
document.getElementById("clickMe").dispatchEvent(e);
}
}, 0);
</script>
</body>
</html>


不会用的可以加微信 iamcpl咨询

                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐