自动填写的WebView领域 [英] Fill fields in webview automatically

查看:161
本文介绍了自动填写的WebView领域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经看到了这个问题漂浮在互联网附近,但我还没有找到一个有效的解决方案呢。基本上,我想加载我的应用程序和preSS按钮;那么按钮操作将填补在web视图已加载的网站用户名和密码(或等待onPageFinished)。最后,在登录页面上的提交按钮将被激活。

I have seen this question floating around the internet, but I haven't found a working solution yet. Basically, I want to load my app and press a button; the button action will then fill in a username and password in a website already loaded in the webview (or wait for onPageFinished). Finally, the submit button on the login page will be activated.

据我了解,这可以通过做一个java注射使用loadURL(JavaScript的)来完成,但我不知道什么是Java命令将是填补了领域。同样的问题被问了<一href="http://stackoverflow.com/questions/7729473/can-i-use-username-and-password-information-from-uitextfields-to-log-onto-a-webs">iOS,但是命令是稍有不同。

From what I understand this can be done by doing a java injection with the loadUrl(javascript), but I don't know what the java commands would be to fill in the fields. The same question was asked for iOS, but the commands are slightly different.

是否有可能做我的JavaScript是问在webivew,或做我必须做一个HTTP-POST不一样的这个或<一href="http://stackoverflow.com/questions/6960909/how-to-autofill-gmail-form-from-a-webview-with-basicnamevaluepair">this?

Is it possible to do what I am asking with javascript in a webivew, or do I have to do a http-post without a webview like this or this?

感谢你这么多的帮助,你可以给!

Thank you so much for any help you can give!

推荐答案

您不需要使用的java命令......而是JavaScript的......例如:

You don't need to use "java commands"... but instead JavaScript... for instance:

String username = "cristian";
webview.loadUrl("javascript:document.getElementById('username').value = '"+username+"';");

因此​​,基本上,你所要做的就是JavaScript的code,将让这些字段,并把价值观对他们的大串;另外,还可以启用/禁用通过JavaScript提交按钮。

So basically, what you have to do is a big string of JavaScript code that will get those fields and put values on them; also, you can enable/disable the submit button from JavaScript.

这篇关于自动填写的WebView领域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆