0
"https://foo.com/default?companyId=1929770&authorizationSource=FTP", 과 같은 기본 URL을 호출했습니다. 기본 URL을로드하면 "https://foo.com/default?companyId=1929770&authorizationSource=FTP_123456789"과 같은 보조 URL로 리디렉션됩니다. 보조 URL은 항상 끝에 숫자가있는 FTP를 임의로 생성합니다. 보조 URL에 대해 javascript를 어떻게 실행할 수 있습니까?Android 실행 리디렉션 웹보기의 JavaScript
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()");
}
});
}
는 로그 캣 :이 내부처럼 JS 코드를 실행할 수 있습니다
[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)
해결책이 작동하지 않습니다. – mario
괜찮습니다. 일부 로그를 추가하십시오. inside onPageFinished() 그리고 당신이 succes을 가지기를 바랍니다. –