Giter VIP home page Giter VIP logo

appkit.js's Introduction

appkit.js

JS调用Android/iOS方法的封装,支持iOS的WKWebView,可判断网页是否在APP浏览器中,是否在微信浏览器中

说明文档

demo.html 里有范例代码

Android/iOS的定义规则

  • iOS使用WKWebView后无法自定义JS对象名,默认为webkit,所以不用动
  • 修改Android的JS对象名为adwebkit
  • Android/iOS定义的方法名需统一

建立对象

引用后脚本后,默认会建立一个 appkit 对象,可直接使用

JS调用Android/iOS的方法

调用自家APP中带参数的方法

// 第一个参数为Android/iOS定义的方法名,第二个参数为json字符串参数
appkit.callApp("HtmlGetLocation", '{"lat": 116.436464,"lng":40.024643}');

调用自家APP中不带参数的方法

appkit.callApp("HtmlGetLocation");

判断网页是否在微信浏览器中

if(appkit.isWeixin()){
	alert("true");
}else{
	alert("false");
}

判断网页是否在微信APP版的浏览器中

if(appkit.isWeixinApp()){
	alert("true");
}else{
	alert("false");
}

判断网页是否在微信PC版的浏览器中

if(appkit.isWeixinPC()){
	alert("true");
}else{
	alert("false");
}

判断网页是否在自家APP浏览器中

if(appkit.isApp()){
	alert("true");
}else{
	alert("false");
}

appkit.js's People

Contributors

onanying avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.