-2

我正在尝试将 javascript 加载到 UIWebview 中,这是 javascript 代码

<script type=\"text/javascript\">
window.external =
{
    'Notify': function(s) { document.location = 'acs://settoken?token=' + s; },
    'notify': function(s) { document.location = 'acs://settoken?token=' + s; }
};
</script>

- (void) webViewDidFinishLoad:(UIWebView *)webView
{
   //Here how to call the above javascript
  [webView stringByEvaluatingJavaScriptFromString:@"";
}
4

2 回答 2

3

关闭 webview 语句。你的代码应该是这样的:

[webView stringByEvaluatingJavaScriptFromString:@"window.external =\
{\
'Notify': function(s) { document.location = 'acs://settoken?token=' + s; },\
'notify': function(s) { document.location = 'acs://settoken?token=' + s; }\
}"];
于 2013-04-25T04:19:20.300 回答
2

您可以使用此方法调用javascriptfrom htmltoiOS webview

  [self.webView stringByEvaluatingJavaScriptFromString:@"my_html_function();"];

这可能会对您有所帮助。

于 2013-04-25T04:13:19.383 回答