添加数据到 webview html input in android
add data to webview html input in android
我有一个 webview,我正在尝试加载一个如下图所示的网页,有一个下拉菜单和两个输入需要通过填充我们在 android webview 中给出的这些值来加载它
我试过这段代码,但它不起作用
final String sectionName = getIntent().getStringExtra("sectionName");
final String consumerNumber = getIntent().getStringExtra("consumerNumber");
final String billNumber = getIntent().getStringExtra("billNumber");
this.web = (WebView) findViewById(R.id.web);
this.web.loadUrl(Constants.Payment_URL);
this.web.getSettings().setJavaScriptEnabled(true);
this.web.setWebViewClient(new WebViewClient() {
public void onPageFinished(WebView view, String url) {
Log.e("TAG", "sectionName:" + sectionName);
view.loadUrl("javascript:$($(\"#sectionCode option\")[" + sectionName + "]).prop('selected','selected');$('#ConsumerNo').val('" + consumerNumber + "');$('#billNo').val('" + billNumber + "');");
}
public void onPageStarted(WebView view, String url, Bitmap favicon) {
super.onPageStarted(view, url, favicon);
}
});
我需要网页视图加载程序中给定的那些值enter image description here
是的,您可以在 javascript 的帮助下做到这一点。
您可以通过多种方式将 javascript 注入您的网络视图。
我建议您使用 JavaSCript 注入器库。你可以在这里找到它。
我有一个 webview,我正在尝试加载一个如下图所示的网页,有一个下拉菜单和两个输入需要通过填充我们在 android webview 中给出的这些值来加载它
我试过这段代码,但它不起作用
final String sectionName = getIntent().getStringExtra("sectionName");
final String consumerNumber = getIntent().getStringExtra("consumerNumber");
final String billNumber = getIntent().getStringExtra("billNumber");
this.web = (WebView) findViewById(R.id.web);
this.web.loadUrl(Constants.Payment_URL);
this.web.getSettings().setJavaScriptEnabled(true);
this.web.setWebViewClient(new WebViewClient() {
public void onPageFinished(WebView view, String url) {
Log.e("TAG", "sectionName:" + sectionName);
view.loadUrl("javascript:$($(\"#sectionCode option\")[" + sectionName + "]).prop('selected','selected');$('#ConsumerNo').val('" + consumerNumber + "');$('#billNo').val('" + billNumber + "');");
}
public void onPageStarted(WebView view, String url, Bitmap favicon) {
super.onPageStarted(view, url, favicon);
}
});
我需要网页视图加载程序中给定的那些值enter image description here
是的,您可以在 javascript 的帮助下做到这一点。
您可以通过多种方式将 javascript 注入您的网络视图。
我建议您使用 JavaSCript 注入器库。你可以在这里找到它。