0
我的Objective-C代碼看起來是這樣的:依奧斯的WebView調用javascript函數不會工作
NSString *test = [NSString stringWithFormat: @"testFunction(%@)", details.name];
NSString *userName = [webView stringByEvaluatingJavaScriptFromString:test];
NSLog(@"Web response: %@",test);
此打印出testFunction(the string of details.name here)
。
我的JavaScript看起來像這樣:
<script type="text/javascript">document.write(title);</script>
var title;
function testFunction(var) {
title = var;
}