J'appelle l'URL primaire comme "https://foo.com/default?companyId=1929770&authorizationSource=FTP", Lorsque je charge l'URL primaire je serai redirigé vers l'URL secondaire comme "https://foo.com/default?companyId=1929770&authorizationSource=FTP_123456789". URL secondaire génère toujours FTP avec un nombre à la fin au hasard. Comment puis-je exécuter javascript pour l'URL secondaire?Exécution Android JavaScript dans la redirection webview
public class ActivityWebViewPay extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String privatURL = "https://foo.com/default?companyId=1929770&authorizationSource=FTP&account=" + getIntent().getStringExtra(ACCOUNT_LS);
WebView urlWebView = new WebView(this);
setContentView(urlWebView);
urlWebView.getSettings().setJavaScriptEnabled(true);
urlWebView.getSettings().setDomStorageEnabled(true);
WebSettings settingsURL = urlWebView.getSettings();
settingsURL.setMinimumFontSize(18);
settingsURL.setBuiltInZoomControls(true);
settingsURL.setDisplayZoomControls(true);
settingsURL.setJavaScriptEnabled(true);
settingsURL.setDomStorageEnabled(true);
urlWebView.clearHistory();
urlWebView.clearCache(true);
urlWebView.loadUrl(privatURL);
urlWebView.setWebViewClient(new WebViewClient(){
@Override
public void onPageFinished(WebView view, String url) {
view.loadUrl("javascript:function a(){window.document.getElementsByClassName('property-info-wrap')[0].style.display='none';}; a()");
}
});
}
logcat:
[INFO:CONSOLE(1)] "Uncaught TypeError: Cannot read property 'style' of undefined", source: (1)
[INFO:CONSOLE(1)] "Uncaught TypeError: Cannot read property 'style' of undefined", source: (1)
[INFO:CONSOLE(22)] "Start Referrer is >>> ", source: link without FTP (22)
[INFO:CONSOLE(1)] "Uncaught TypeError: Cannot read property 'style' of undefined", source: (1)
[INFO:CONSOLE(5)] "The key "target-densitydpi" is not supported.", source: link with FTP (5)
[INFO:CONSOLE(30)] "referer ", source: link with FTP (30)
[INFO:CONSOLE(1)] "Uncaught TypeError: Cannot read property 'style' of undefined", source: (1)
votre solution ne fonctionne pas – mario
ça marche très bien pour moi. essayez d'ajouter quelques journaux. à l'intérieur onPageFinished() et j'espère que vous aurez un succès –