我想将一个文本变量从 JavaScript 传递给一个 Objective-C 变量。
我的 HTML 文件如下所示:
<p>Bitte tragen Sie die Document ID ein:</p>
<SCRIPT TYPE="text/javascript">
function testResults(form){
location.href = DocumentID.value;
}
</SCRIPT>
<form action="">
<table border="0" cellpadding="5" cellspacing="0" bgcolor="#E0E0E0">
<tr>
<td align="right">Document ID:</td>
<td><input name="DocumentID" type="text" size="30" maxlength="30" value="35060e6242160705744ffd8e280005b9"></td>
</tr>
<tr>
<td align="right">Formular:</td>
<td>
<input type="button" NAME ="button" value=" Absenden " onClick="testResults(this.form)">
<input type="reset" value=" Abbrechen">
</td>
</tr>
</table>
</form>
这是 Objective-C 代码:
-(BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
if([request.URL.relativeString isEqualToString:@"http://localhost:8888/"])
//if([request.URL.relativeString rangeOfString:@"http://localhost:8888/"].location)
{
//self.URL
[self loadData];
return true;
}
return true;
}
有人可以给我一个提示吗?谢谢!