2

我想在 UIWebView 中加载 .js(javaScript) 文件,而不仅仅是一个函数

 [webView stringByEvaluatingJavaScriptFromString:@""];
4

1 回答 1

3
NSString *javaScript=[NSString stringWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"javascript" ofType:@"js"] encoding:NSUTF8StringEncoding error:nil];

[webView stringByEvaluatingJavaScriptFromString:javaScript];

[1] http://www.iphonedevsdk.com/forum/iphone-sdk-development/22703-loading-local-javascript-file-into-uiwebview-problem.html

[2] http://iphoneincubator.com/blog/windows-views/how-to-inject-javascript-functions-into-a-uiwebview

于 2012-04-30T06:48:53.047 回答