点击网页上的的<img 标签,我想在标签上添加一个onclick 并跳转到我app内部的某一个avtivity
Android:
webView.getSettings().setJavaScriptEnabled(true);
webView.addJavascriptInterface(new JSHook(), "android");
public class JSHook{
public JsHook(Context context){
}
public void goActivity(){
startactivity(new Intent(context,class));
}
}
html
<html xmlns="http://www.w3.org/1999/xhtml">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>调用Android组件测试</title>
</head>
<body>
<b>测试</b>
<br />
<button onClick="window.android.goActivity()">跳转 Activity</button>
</body>
</html>
你让web在图片写一个点击跳转事件 跳转到指定url 然后你拦截这个指定url就可以做你想要的操作了