我的Objective-C代码如下所示:
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;
}
在JS中,您关闭了第一行中的script标签,而忽略了该功能
您的JS应该看起来像这样
<script type="text/javascript">document.write(title);
var title;
function testFunction(var) {
title = var;
}
</script>
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句