0
我打電話javascript code
並閱讀了很多活動,並開放到它將鉗位模擬器,但不是在移動的地址。加載webView.loadUrl(「file:///android_asset/test.html」);到模擬器不加載移動
代碼:
web_pay.getSettings().setJavaScriptEnabled(true);
web_pay.getSettings().setDomStorageEnabled(true);
JSInterface = new JavaScriptInterface();
web_pay.addJavascriptInterface(JSInterface, "cc");
web_pay.setWebViewClient(new WebViewClient() {
@Override
public void onPageFinished(WebView view, String url) { web_pay.loadUrl("javascript:window.cc.show(document.getElementsByTagName('html')[0].innerHTML);");
}
@Override
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
handler.proceed();
}
});
web_pay.loadUrl("file:///android_asset/test.html");
}
public class JavaScriptInterface {
// Context mContext;
// Instantiate the interface and set the context
// JavaScriptInterface(Context c) {
// mContext = c;
// }
public String changeActivity() {
Toast.makeText(pay.this, "lode
}
代碼:JavaScript的
<html>
<head>
<body onload="test1();">
</body>
<script>
function test(a){
var form = document.createElement("form");
form.setAttribute("method", "POST");
form.setAttribute("action", "https://bpm.shaparak.ir/pgwchannel/startpay.mellat");
form.setAttribute("target", "_self");
var hiddenField = document.createElement("input");
hiddenField.setAttribute("name", "RefId");
hiddenField.setAttribute("value",a);
form.appendChild(hiddenField);
document.body.appendChild(form);
form.submit();
document.body.removeChild(form);
}
function test1(){
var a=cc.changeActivity();`enter code here`
test(a);
}
</script>
</head>
</html>