所以我遇到了一个问题,那里有一个按钮将调用Webview函数
按钮是index.html中ID为[[play的按钮,它将调用src.js中的javascript playVideo函数,其中playVideo函数将通知Webview已按下按钮以检查Java Function中的条件。我该如何实现?
下面的代码有助于获得上下文
index.html
<!DOCTYPE html>
<html>
<head>
<title> Video</title>
<script type="text/javascript" src="src.js"></script>
</head>
<body bgcolor="#333">
<center>
<video preload="auto" width="480" height="270"
#Embed-video
</video>
<br>
<br>
<div>
<a class="first" href="#" id="play">Play</a>
<a class="second" href="#" id="pause">Pause</a>
</div>
</center>
Javascript代码
window.onload = function(){
var video = document.getElementById('my-video');
var play = document.getElementById('play');
var pause = document.getElementById('pause');
// associate functions with the 'onclick' events
play.onclick = playVideo;
pause.onclick = pauseVideo;
function playVideo(e) {
//call java function
}
function pauseVideo(e) {
}
}
Java函数
webView.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(x,y) {
if (js.playVideo()) {
//do something
return true;
}else{
return false;
}
}
});
所以我遇到了一个问题,那里有一个将调用Webview函数的按钮。该按钮是index.html中具有ID播放的按钮,它将在src.js中调用javascript playVideo函数,其中...