Send a javascript command to a Webview using variables gotten with an EditText

I am in the process of creating a simple webapp for which the user wouldn't have to input his credentials each time he opens the website (no possibility to save the password). I managed to find the form's fields and submit action and it is possible through Crome's console to login when the following lines are submitted.

document.getElementById('zonePwd').value="Password"
document.getElementById('zoneId').value="Id"
GInterface.traiterEvenementValidation()

Now, on my webapp, I'd like to know if it would be possible to do the same thing using strings after the user fills a dialog with both information.

Be sure to say so if I'm not clear enough

Thanks

PS: I'm very new with JS

Answers:

Answer

I recommand you to create a javascript function like :

function setCredentials(id, pass)
{
    document.getElementById('zonePwd').value=pass;
    document.getElementById('zoneId').value=id;
    GInterface.traiterEvenementValidation();
}

And then from your app code

String id = "myid"; //Get val from the dialog
String pass = "mypass"; //Get val from the dialog
webview.loadUrl("javascript:setCredentials('"+id+"','"+pass+"')");

Hope it helps ;)

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.