如何从android -Cordova/Phonegap调用javascript函数 [英] How to call javascript function from android -Cordova/Phonegap
本文介绍了如何从android -Cordova/Phonegap调用javascript函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用cordova/phonegap制作一个Android应用,并尝试从android/native调用JavaScript函数
I'm using cordova/phonegap to make a Android app and trying to call JavaScript funtion from android/native
我的主要活动:-
public class MainActivity extends CordovaActivity
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
// Set by <content src="index.html" /> in config.xml
loadUrl(Url);
// TODO call javascripte from here
}
}
我的index.html页面
My index.html page
<!DOCTYPE HTML>
<html>
<head>
<title>PhoneGap</title>
<script type="text/javascript" charset="utf-8">
function myFun(){
alert("call from the ANDROID");
}
</script>
</head>
<body >
</body>
</html>
我想从phonegap调用JavaScript函数.
I want call JavaScript function from phonegap.
推荐答案
尝试此代码
webView.loadUrl("javascript:myFun()");
这篇关于如何从android -Cordova/Phonegap调用javascript函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文