참고: WeChat에서 테스트해 보세요.
<!DOCTYPE html> <html> <head> <title>微信WeixinJSBridge API</title> <meta charset="utf-8" /> <script type="text/javascript"> (function(){ var a=document.getElementsByTagName("html")[0]; window.Session={appDomain:a.getAttribute("data-app-domain")||"",staticDomain:a.getAttribute("data-static-domain")||""} })(); window.registNS=function(fullNS,isIgnorSelf){ var reg=/^[_$a-z]+[_$a-z0-9]*/i;var nsArray=fullNS.split("."); var sEval=""; var sNS=""; var n=isIgnorSelf?nsArray.length-1:nsArray.length; for(var i=0;i<n;i++){ if(!reg.test(nsArray[i])){throw new Error("Invalid namespace:"+nsArray[i]+""); return } if(i!=0){sNS+="."} sNS+=nsArray[i]; sEval+="if(typeof("+sNS+")=='undefined') "+sNS+"=new Object(); else "+sNS+";" } if(sEval!=""){ return eval(sEval) } return{} }; </script> </head> <body> <section class="mod-page-body"> <div class="mod-page-main wordwrap clearfix"> <div class="mod-pageheader"></div> <div class="mod-pagecontent"> <div class="mod-weixinjsapi"> <div class="x-desc"> 微信客户端自带的Js Api:WeixinJSBridge </div> <div id="WeixinJsApi"> <input type="button" id="imagePreview" value="图片预览" /> <input type="button" id="profile" value="查看profile" /> <a href="weixin://profile/gh_412d74fbb474">企业微信小助手</a> <input type="button" id="shareWeibo" value="分享微博" /> <input type="button" id="shareFB" value="分享facebook" /> <input type="button" id="addContact" value="添加联系人" /> <input type="button" id="scanQRCode" value="扫描二维码" /> <input type="button" id="jumpToBizProfile" value="跳转到指定公众账号页面" /> <input type="button" id="toggleMenuBtn" value="隐藏右上角按钮" /> <input type="button" id="toggleToolbar" value="隐藏底部导航栏" /> <input type="button" id="getNetType" value="获取网络状态" /> <input type="button" id="closeWindow" value="关闭" /> <input type="button" id="getBrandWCPayRequest" value="发起公众号微信支付" /> <input type="button" id="setPageState" value="设置页面状态" /> <input type="button" id="sendEmail" value="发邮件" /> <input type="button" id="openSpecificView" value="微信团队打开webView,跳到指定页面" /> <input type="button" id="getCanIAPPay" value="getCanIAPPay" /> <input type="button" id="getBrandIAPPayRequest" value="发起公众号IAP支付" /> <input type="button" id="openUrlByExtBrowser" value="用safari打开指定链接" /> <input type="button" id="openProductView" value="跳转微信商品页" /> <input type="button" id="openLocation" value="查看地理位置" /> <input type="button" id="timelineCheckIn" value="朋友圈签到" /> <input type="button" id="getBrandWCPayCreateCreditCardRequest" value="开通微信信用卡" /> <input type="button" id="geoLocation" value="获取地理位置" /> <input type="button" id="getInstallState" value="获取某app是否安装" /> <input type="button" id="editAddress" value="公众号编辑收货地址" /> <input type="button" id="getLatestAddress" value="公众号获取最近的收货地址" /> <input type="button" id="launch3rdApp" value="启动第三方APP" /> <input type="button" id="jumpWCMall" value="跳转微信商品购买界面" /> <input type="button" id="addEmoticon" value="添加表情" /> <input type="button" id="cancelAddEmoticon" value="取消下载某表情" /> <input type="button" id="hasEmoticon" value="查询是否存在某表情" /> </div> </div> </div> </div> </section> <script> function onBridgeReady() { WeixinJSBridge.on('menu:share:appmessage', function(argv) { WeixinJSBridge.invoke('sendAppMessage',{ "link":"http://m.exmail.qq.com/", "desc":"desc", "title":"title for WeiXinJsBridge" }, function(res) { WeixinJSBridge.log(res.err_msg); }); }); WeixinJSBridge.on('menu:share:timeline', function(argv) { WeixinJSBridge.invoke("shareTimeline",{ "link":"http://m.exmail.qq.com", "img_url":"http://rescdn.qqmail.com/bizmail/zh_CN/htmledition/images/bizmail/v3/logo1ca3fe.png", "img_width":"172", "img_height":"40", "desc":"i am description", "title":"just test from WeixinJsBridge" }, function(e){ alert(e.err_msg); }) }); } if (typeof WeixinJSBridge === "undefined"){ if (document.addEventListener){ document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false); } }else{ onBridgeReady(); } var menuHidden=!1,toolbarHidden=!1,netType={"network_type:wifi":"wifi网络","network_type:edge":"非wifi,包含3G/2G","network_type:fail":"网络断开连接","network_type:wwan":"2g或者3g"}; document.addEventListener("WeixinJSBridgeReady",function(){ document.getElementById("imagePreview").addEventListener( "click",function(){ WeixinJSBridge.invoke("imagePreview",{ "urls":[ "http://rescdn.qqmail.com/bizmail/zh_CN/htmledition/images/bizmail/v3/logo1ca3fe.png", "http://rescdn.qqmail.com/bizmail/zh_CN/htmledition/images/bizmail/v3/icons_features1ca3fe.png", "http://rescdn.qqmail.com/bizmail/zh_CN/htmledition/images/bizmail/v3/icons_workStyle1ca3fe.png" ], "current":"http://rescdn.qqmail.com/bizmail/zh_CN/htmledition/images/bizmail/v3/icons_features1ca3fe.png" }) },!1), document.getElementById("profile").addEventListener( "click",function(){ alert("profile clicked"); WeixinJSBridge.invoke("profile",{ "username":"gh_412d74fbb474", "nickname":"企业微信小助手" }) },!1), document.getElementById("shareWeibo").addEventListener( "click",function(){ WeixinJSBridge.invoke("shareWeibo",{ "type":"link", "link":"http://m.exmail.qq.com" }, function(e){ alert(e.err_msg); }) },!1), document.getElementById("shareFB").addEventListener( "click",function(){ WeixinJSBridge.invoke("shareFB",{ "link":"http://m.exmail.qq.com" }) },!1), document.getElementById("scanQRCode").addEventListener( "click",function(){ WeixinJSBridge.invoke("scanQRCode",{ }) },!1), document.getElementById("addEmoticon").addEventListener( "click",function(){ WeixinJSBridge.invoke("addEmoticon",{ "url":"http://rescdn.qqmail.com/bizmail/zh_CN/htmledition/images/bizmail/v3/icons_features1ca3fe.png", "thumb_url":"http://rescdn.qqmail.com/bizmail/zh_CN/htmledition/images/bizmail/v3/logo1ca3fe.png" }, function(e){ alert(e.err_msg); }) },!1), document.getElementById("cancelAddEmoticon").addEventListener( "click",function(){ WeixinJSBridge.invoke("cancelAddEmoticon",{ "url":"http://rescdn.qqmail.com/bizmail/zh_CN/htmledition/images/bizmail/v3/icons_features1ca3fe.png" }, function(e){ alert(e.err_msg); }) },!1), document.getElementById("hasEmoticon").addEventListener( "click",function(){ WeixinJSBridge.invoke("hasEmoticon",{ "url":"http://rescdn.qqmail.com/bizmail/zh_CN/htmledition/images/bizmail/v3/icons_features1ca3fe.png" }, function(e){ alert(e.err_msg); }) },!1), document.getElementById("addContact").addEventListener( "click",function(){ WeixinJSBridge.invoke("addContact",{ "webtype":"1", "username":"gh_412d74fbb474" }, function(e){ alert(e.err_msg); }) },!1), document.getElementById("jumpToBizProfile").addEventListener( "click",function(){ WeixinJSBridge.invoke("jumpToBizProfile",{ "tousername":"gh_2248a2ade13e" }, function(e){ alert(e.err_msg); }) },!1), document.getElementById("toggleMenuBtn").addEventListener( "click",function(){ menuHidden? (WeixinJSBridge.call("showOptionMenu"),menuHidden=!1,this.value="隐藏右上角按钮") : (WeixinJSBridge.call("hideOptionMenu"),menuHidden=!0,this.value="显示右上角按钮") },!1), document.getElementById("toggleToolbar").addEventListener( "click",function(){ toolbarHidden? (WeixinJSBridge.call("showToolbar"),toolbarHidden=!1,this.value="隐藏底部导航栏") : (WeixinJSBridge.call("hideToolbar"),toolbarHidden=!0,this.value="显示底部导航栏") },!1), document.getElementById("getNetType").addEventListener( "click",function(){ WeixinJSBridge.invoke("getNetworkType",{}, function(e){ alert(netType[e.err_msg]) }) },!1), document.getElementById("closeWindow").addEventListener( "click",function(){ WeixinJSBridge.invoke("closeWindow",{},function(e){}) },!1), document.getElementById("getBrandWCPayRequest").addEventListener( "click",function(){ WeixinJSBridge.invoke("getBrandWCPayRequest",{ "appId" : "wxf8b4f85f3a794e77", //公众号名称,由商户传入 "timeStamp" : "189026618", //时间戳 这里随意使用了一个值 "nonceStr" : "adssdasssd13d", //随机串 "package" : "body=xxx&fee_type=1&input_charset=GBK¬ify_url=http&out_trade_no=16642817866003386000&partner=1900000109&return_url=http&spbill_create_ip=127.0.0.1&total_fee=1&sign=273B7EEEE642A8E41F27213D8517E0E4", //扩展字段,由商户传入 "signType" : "SHA1", //微信签名方式:sha1 "paySign" : "b737015b5b1eabe5db580945a07eac08c7bb55f8" //微信签名 }, function(e){ alert(e.err_msg) }) },!1), document.getElementById("setPageState").addEventListener( "click",function(){ WeixinJSBridge.invoke("setPageState",{ "state" : "1" }) },!1), document.getElementById("sendEmail").addEventListener( "click",function(){ WeixinJSBridge.invoke("sendEmail",{ "title" : "title!", "content" : "i am an Email!", //时间戳 这里随意使用了一个值 }, function(e){ // alert(e.err_msg) }) },!1), document.getElementById("openSpecificView").addEventListener( "click",function(){ WeixinJSBridge.invoke("openSpecificView",{ "specificview" : "contacts" }, function(e){ alert(e.err_msg) }) },!1), document.getElementById("getCanIAPPay").addEventListener( "click",function(){ WeixinJSBridge.invoke("getCanIAPPay",{ }, function(e){ alert(e.err_msg) }) },!1), document.getElementById("getBrandIAPPayRequest").addEventListener( "click",function(){ WeixinJSBridge.invoke("getBrandIAPPayRequest",{ "appId" : "wxf8b4f85f3a794e77", //公众号名称,由商户传入 "timeStamp" : "189026618", //时间戳 这里随意使用了一个值 "nonceStr" : "adssdasssd13d", //随机串 "package" : "bankType=CITIC_CREDIT&bankName=%e4%b8%ad%e4%bf%a1%e9%93%b6%e8%a1%8c&sign=CF8922F49431FFE8A1834D0B32B25CE3", //扩展字段,由商户传入 "signType" : "SHA1", //微信签名方式:sha1 "paySign" : "1e6f13f78ca0ec43fbb80899087f77568af66987" //微信签名 }, function(e){ alert(e.err_msg) }) },!1), document.getElementById("openLocation").addEventListener( "click",function(){ WeixinJSBridge.invoke("openProductView",{ "latitude" : 23.113, //纬度 "longitude" : 113.23, //经度 "name" : "TIT创意园", //POI名称 "address" : "广州市海珠区新港中路397号", //地址 "scale" : 14, //地图缩放级别 "infoUrl" : "http://weixin.qq.com/", //查看位置界面底部的超链接 }, function(e){ alert(e.err_msg) }) },!1), document.getElementById("timelineCheckIn").addEventListener( "click",function(){ WeixinJSBridge.invoke("timelineCheckIn",{ "img_url": "http://mmsns.qpic.cn/mmsns/RLllkTm3DUdV24xbZnKicx9jJWxXI0Bq84zzbtibGuRyk/0", // 分享到朋友圈的缩略图 "img_width": "640", // 图片的长度 "img_height": "640", // 图片高度 "link": "http://news.qq.com/zt2012/cxkyym/index.htm", // 连接地址 "desc": "这个是描述啊啊", // 描述 "title": "朝鲜称中国渔船越界捕捞", // 分享标题 "latitude" : 23.113, //纬度 "longitude" : 113.23, //经度 "poiId" : "dianping_2331037", //商户id "poiName" : "TIT创意园", //POI名称 "poiAddress" : "广州市海珠区新港中路397号", //地址 "poiScale" : 14, //地图缩放级别 "poiInfoUrl" : "http://weixin.qq.com/" //查看位置界面底部的超链接 }, function(e){ alert(e.err_msg) }) },!1), document.getElementById("geoLocation").addEventListener( "click",function(){ WeixinJSBridge.invoke("geoLocation",{ }, function(e){ alert(e.err_msg) }) },!1), document.getElementById("getBrandWCPayCreateCreditCardRequest").addEventListener( "click",function(){ WeixinJSBridge.invoke("getBrandWCPayCreateCreditCardRequest",{ "appId" : "wxf8b4f85f3a794e77", //公众号名称,由商户传入 "timeStamp" : "189026618", //时间戳 这里随意使用了一个值 "nonceStr" : "adssdasssd13d", //随机串 "package" : "bankType=CITIC_CREDIT&bankName=%e4%b8%ad%e4%bf%a1%e9%93%b6%e8%a1%8c&sign= CF8922F49431FFE8A1834D0B32B25CE3", //扩展字段,由商户传入 "signType" : "SHA1", //微信签名方式:sha1 "paySign" : "1e6f13f78ca0ec43fbb80899087f77568af66987" //微信签名 }, function(e){ alert(e.err_msg) }) },!1), document.getElementById("getInstallState").addEventListener( "click",function(){ WeixinJSBridge.invoke("getInstallState",{ "packageUrl":"teamcircle://" }, function(e){ alert(e.err_msg) }) },!1), document.getElementById("openProductView").addEventListener( "click",function(){ WeixinJSBridge.invoke("openProductView",{ "productInfo":"json" }, function(e){ alert(e.err_msg) }) },!1), document.getElementById("getLatestAddress").addEventListener( "click",function(){ WeixinJSBridge.invoke("getLatestAddress",{ "appId" : "wxf8b4f85f3a794e77", //公众号名称,由商户传入 "timeStamp" : "189026618", //时间戳 这里随意使用了一个值 "nonceStr" : "adssdasssd13d", //随机串 "signType" : "SHA1", //微信签名方式:sha1 "addrSign" : "b737015b5b1eabe5db580945a07eac08c7bb55f8", //微信签名 "scope" : "snsapi" }, function(e){ alert(e.err_msg) }) },!1), document.getElementById("editAddress").addEventListener( "click",function(){ WeixinJSBridge.invoke("editAddress",{ "appId" : "wxf8b4f85f3a794e77", //公众号名称,由商户传入 "timeStamp" : "189026618", //时间戳 这里随意使用了一个值 "nonceStr" : "adssdasssd13d", //随机串 "signType" : "SHA1", //微信签名方式:sha1 "addrSign" : "b737015b5b1eabe5db580945a07eac08c7bb55f8", //微信签名 "scope" : "snsapi" }, function(e){ alert(e.err_msg) }) },!1), document.getElementById("launch3rdApp").addEventListener( "click",function(){ WeixinJSBridge.invoke("launch3rdApp",{ "appId" : "wx5823bf96d3bd56c7", //公众号名称,由商户传入 }, function(e){ alert(e.err_msg) }) },!1), document.getElementById("jumpWCMall").addEventListener( "click",function(){ WeixinJSBridge.invoke("jumpWCMall",{ "appId" : "wx5823bf96d3bd56c7", //公众号名称,由商户传入 "funcId":"1000" }, function(e){ alert(e.err_msg) }) },!1), document.getElementById("openUrlByExtBrowser").addEventListener( "click",function(){ WeixinJSBridge.invoke("openUrlByExtBrowser",{ "url" : "http://m.exmail.qq.com" }, function(e){ alert(e.err_msg) }) },!1) } ); </script> </body> </html>

C 및 JavaScript는 WebAssembly를 통한 상호 운용성을 달성합니다. 1) C 코드는 WebAssembly 모듈로 컴파일되어 컴퓨팅 전력을 향상시키기 위해 JavaScript 환경에 도입됩니다. 2) 게임 개발에서 C는 물리 엔진 및 그래픽 렌더링을 처리하며 JavaScript는 게임 로직 및 사용자 인터페이스를 담당합니다.

JavaScript는 웹 사이트, 모바일 응용 프로그램, 데스크탑 응용 프로그램 및 서버 측 프로그래밍에서 널리 사용됩니다. 1) 웹 사이트 개발에서 JavaScript는 HTML 및 CSS와 함께 DOM을 운영하여 동적 효과를 달성하고 jQuery 및 React와 같은 프레임 워크를 지원합니다. 2) 반응 및 이온 성을 통해 JavaScript는 크로스 플랫폼 모바일 애플리케이션을 개발하는 데 사용됩니다. 3) 전자 프레임 워크를 사용하면 JavaScript가 데스크탑 애플리케이션을 구축 할 수 있습니다. 4) node.js는 JavaScript가 서버 측에서 실행되도록하고 동시 요청이 높은 높은 요청을 지원합니다.

Python은 데이터 과학 및 자동화에 더 적합한 반면 JavaScript는 프론트 엔드 및 풀 스택 개발에 더 적합합니다. 1. Python은 데이터 처리 및 모델링을 위해 Numpy 및 Pandas와 같은 라이브러리를 사용하여 데이터 과학 및 기계 학습에서 잘 수행됩니다. 2. 파이썬은 간결하고 자동화 및 스크립팅이 효율적입니다. 3. JavaScript는 프론트 엔드 개발에 없어서는 안될 것이며 동적 웹 페이지 및 단일 페이지 응용 프로그램을 구축하는 데 사용됩니다. 4. JavaScript는 Node.js를 통해 백엔드 개발에 역할을하며 전체 스택 개발을 지원합니다.

C와 C는 주로 통역사와 JIT 컴파일러를 구현하는 데 사용되는 JavaScript 엔진에서 중요한 역할을합니다. 1) C는 JavaScript 소스 코드를 구문 분석하고 추상 구문 트리를 생성하는 데 사용됩니다. 2) C는 바이트 코드 생성 및 실행을 담당합니다. 3) C는 JIT 컴파일러를 구현하고 런타임에 핫스팟 코드를 최적화하고 컴파일하며 JavaScript의 실행 효율을 크게 향상시킵니다.

실제 세계에서 JavaScript의 응용 프로그램에는 프론트 엔드 및 백엔드 개발이 포함됩니다. 1) DOM 운영 및 이벤트 처리와 관련된 TODO 목록 응용 프로그램을 구축하여 프론트 엔드 애플리케이션을 표시합니다. 2) Node.js를 통해 RESTFULAPI를 구축하고 Express를 통해 백엔드 응용 프로그램을 시연하십시오.

웹 개발에서 JavaScript의 주요 용도에는 클라이언트 상호 작용, 양식 검증 및 비동기 통신이 포함됩니다. 1) DOM 운영을 통한 동적 컨텐츠 업데이트 및 사용자 상호 작용; 2) 사용자가 사용자 경험을 향상시키기 위해 데이터를 제출하기 전에 클라이언트 확인이 수행됩니다. 3) 서버와의 진실한 통신은 Ajax 기술을 통해 달성됩니다.

보다 효율적인 코드를 작성하고 성능 병목 현상 및 최적화 전략을 이해하는 데 도움이되기 때문에 JavaScript 엔진이 내부적으로 작동하는 방식을 이해하는 것은 개발자에게 중요합니다. 1) 엔진의 워크 플로에는 구문 분석, 컴파일 및 실행; 2) 실행 프로세스 중에 엔진은 인라인 캐시 및 숨겨진 클래스와 같은 동적 최적화를 수행합니다. 3) 모범 사례에는 글로벌 변수를 피하고 루프 최적화, Const 및 Lets 사용 및 과도한 폐쇄 사용을 피하는 것이 포함됩니다.

Python은 부드러운 학습 곡선과 간결한 구문으로 초보자에게 더 적합합니다. JavaScript는 가파른 학습 곡선과 유연한 구문으로 프론트 엔드 개발에 적합합니다. 1. Python Syntax는 직관적이며 데이터 과학 및 백엔드 개발에 적합합니다. 2. JavaScript는 유연하며 프론트 엔드 및 서버 측 프로그래밍에서 널리 사용됩니다.


핫 AI 도구

Undresser.AI Undress
사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover
사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool
무료로 이미지를 벗다

Clothoff.io
AI 옷 제거제

Video Face Swap
완전히 무료인 AI 얼굴 교환 도구를 사용하여 모든 비디오의 얼굴을 쉽게 바꾸세요!

인기 기사

뜨거운 도구

ZendStudio 13.5.1 맥
강력한 PHP 통합 개발 환경

Eclipse용 SAP NetWeaver 서버 어댑터
Eclipse를 SAP NetWeaver 애플리케이션 서버와 통합합니다.

DVWA
DVWA(Damn Vulnerable Web App)는 매우 취약한 PHP/MySQL 웹 애플리케이션입니다. 주요 목표는 보안 전문가가 법적 환경에서 자신의 기술과 도구를 테스트하고, 웹 개발자가 웹 응용 프로그램 보안 프로세스를 더 잘 이해할 수 있도록 돕고, 교사/학생이 교실 환경 웹 응용 프로그램에서 가르치고 배울 수 있도록 돕는 것입니다. 보안. DVWA의 목표는 다양한 난이도의 간단하고 간단한 인터페이스를 통해 가장 일반적인 웹 취약점 중 일부를 연습하는 것입니다. 이 소프트웨어는

VSCode Windows 64비트 다운로드
Microsoft에서 출시한 강력한 무료 IDE 편집기

SublimeText3 Mac 버전
신 수준의 코드 편집 소프트웨어(SublimeText3)
