我打算使用Javascript
填写本网站上的文字http://customercare.indianrailways.gov.in/criscm/common/complaint_registration.seam
以下是我在下面的WebView的代码
问题是几个输入字段在WebPage中是动态的 我尝试使用.innerHTML并将一些text / html加载到div中,但它没有加载。
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.details1);
mWebView = (WebView)findViewById(R.id.webview);
String s2="http://customercare.indianrailways.gov.in/criscm/common/complaint_registration.seam";
mWebView = (WebView) findViewById(R.id.webview);
mWebView.getSettings().setStandardFontFamily("Arial");
mWebView.getSettings().setDefaultFontSize(17);
if(mWebView.getSettings().getBuiltInZoomControls())
{
}
else
{
}
mWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.loadUrl(s2);
mWebView.setWebChromeClient(new WebChromeClient() {
});
WebViewClient yourWebClient = new WebViewClient()
{
// Override page so it's load on my view only
@Override
public void onPageFinished(WebView view, String url) {
// TODO Auto-generated method stub
//progressBar.setVisibility(View.GONE);
String Staffname = "cristian";
String mode="InTrain";
String date="27/09/2014 07:14";
String contactno="941432344";
String emailid="rdasdamn@gmail.com";
String address1="28 asdasdasdasd";
String address2="Siwerwerweradi";
String address3="Madurai";
String address4="werwer India";
String remarks="Shan asdasdasdas dasdasdas";
/*String html="<div><label for='complaintRegister:causeOfSubComplaint:subCatComplaint' class='name outputText'><label>Sub Complaint :</label><span id='complaintRegister:causeOfSub"
+"Complaint:j_id60' class='required'>*</span></label><span class='value outputText'><table id='complaintRegister:causeOfSubComplaint:subCatComplaint' class='radio'>"
+"<tbody><tr><td><input type='radio' name='complaintRegister:causeOfSubComplaint:subCatComplaint' id='complaintRegister:causeOfSubComplaint:subCatComplaint:0'"
+"value='152' autocomplete='off'><label for='complaintRegister:causeOfSubComplaint:subCatComplaint:0'> Non availability of Manning Staff</label></td>"
+"</tr><tr><td><input type='radio' name='complaintRegister:causeOfSubComplaint:subCatComplaint' id='complaintRegister:causeOfSubComplaint:subCatComplaint:1'"
+"value='153' autocomplete='off'><label for='complaintRegister:causeOfSubComplaint:subCatComplaint:1'> Gates not open during late night hours at the halting"
+"stations</label></td></tr></tbody></table></span><span class='error'></span></div>";*/
mWebView.loadUrl("javascript:"
+ "document.getElementById('complaintRegister:nameOfStaff:nameOfStaff').value = '"+Staffname+"';"
+ "document.getElementById('complaintRegister:complaintMode').value = '"+mode+"';"
+"document.getElementById('complaintRegister:decIncidentDate:incidentDateInputDate').value='"+date+"';"
+"document.getElementById('complaintRegister:contactNumber:contactNo').value='"+contactno+"';"
+"document.getElementById('complaintRegister:emailId:emailId').value='"+emailid+"';"
+"document.getElementById('complaintRegister:address1Id').value='"+address1+"';"
+"document.getElementById('complaintRegister:address2Id').value='"+address2+"';"
+"document.getElementById('complaintRegister:address3Id').value='"+address3+"';"
+"document.getElementById('complaintRegister:address4Id').value='"+address4+"';"
+"document.getElementById('complaintRegister:complaintModePanel:platformNumber').visible='True';"
+"document.getElementById('complaintRegister:complaintModePanel:stationName').visible='True';"
+"document.getElementById('complaintRegister:remarks').value='"+remarks+"';"
+"document.getElementById('complaintRegister:causeOfComplaint').innerHTML='"+"<a href='###'>Shan</a>dsadas"+"';");
super.onPageFinished(view, url);
}
};
mWebView.setWebViewClient(yourWebClient);
// mWebView.setWebChromeClient(new HelloWebViewClient());
}
}