I know it exists a lot of questions about that but i don't understand why my following code does not work anymore
Here is my code :
private void init() {
webview.setWebViewClient(new FormWebViewClient());
webview.postUrl(url, EncodingUtils.getBytes(data, "BASE64"));
}
private class FormWebViewClient extends WebViewClient {
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
super.onPageStarted(view, url, favicon);
// progressBar.setVisibility(View.VISIBLE);
}
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
LOGD(TAG, "Url : " + url);
view.loadUrl(url);
return true;
}
@Override
public void onPageFinished(WebView view, String url) {
view.loadUrl("javascript:" +"document.getElementsByClassName('my_class_name')[0].value = '" + myValue + "';" +
}
}
My original webview is overrided and it displays only myValue
in the page instead of plenty of informations.
If anybody knows why i have this behavior ...
Thx
EDIT :
and the part of html
<input type="text" size="20" maxlength="19" autoplete="off" name="CARD_NUMBER" id="CARD_NUMBER" class="my_class_name" value="">
I know it exists a lot of questions about that but i don't understand why my following code does not work anymore
Here is my code :
private void init() {
webview.setWebViewClient(new FormWebViewClient());
webview.postUrl(url, EncodingUtils.getBytes(data, "BASE64"));
}
private class FormWebViewClient extends WebViewClient {
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
super.onPageStarted(view, url, favicon);
// progressBar.setVisibility(View.VISIBLE);
}
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
LOGD(TAG, "Url : " + url);
view.loadUrl(url);
return true;
}
@Override
public void onPageFinished(WebView view, String url) {
view.loadUrl("javascript:" +"document.getElementsByClassName('my_class_name')[0].value = '" + myValue + "';" +
}
}
My original webview is overrided and it displays only myValue
in the page instead of plenty of informations.
If anybody knows why i have this behavior ...
Thx
EDIT :
and the part of html
<input type="text" size="20" maxlength="19" autoplete="off" name="CARD_NUMBER" id="CARD_NUMBER" class="my_class_name" value="">
Share
Improve this question
edited Dec 25, 2014 at 8:10
mrroboaat
asked Dec 17, 2014 at 10:08
mrroboaatmrroboaat
5,7028 gold badges39 silver badges67 bronze badges
4
-
3
May be this doesn't answer your question but i think you are creating a kind of loop since you call loadUrl inside of
onPageFinished
andloadUrl
– MineConsulting SRL Commented Dec 17, 2014 at 10:13 - Above ment sounds legit. can you post your html file so that we could test it at our end? – Darpan Commented Dec 17, 2014 at 10:15
- In fact, it is a payment webview from Atos so i'm not sure i'm allowed to post html – mrroboaat Commented Dec 17, 2014 at 10:19
- I've added html part – mrroboaat Commented Dec 17, 2014 at 15:22
1 Answer
Reset to default 10Finally, I've found the answer :
I have to add void(0);
at the end of JavaScript instruction like this :
view.loadUrl("javascript:" +"document.getElementsByClassName('my_class_name')[0].value = '" + myValue + "';void(0);")