[英]Cannot get local javascript file to execute when web view loads a remote page
I have worked on this for several days and do not know what I am doing wrong. 我已经为此工作了好几天,不知道我在做什么错。 Any help is appreciated
任何帮助表示赞赏
See code below. 请参见下面的代码。
- (void)webViewDidFinishLoad:(UIWebView *)webView { NSString *jsPath = [[NSBundle mainBundle] pathForResource:@"doc" ofType:@"js" inDirectory:NO]; NSString *js = [NSString stringWithContentsOfFile:jsPath encoding:NSUTF8StringEncoding error:nil]; [webView stringByEvaluatingJavaScriptFromString:js]; }
My javascript file looks like this 我的JavaScript文件如下所示
<script type="text/javascript" >
alert("hello");
</script>
只需从JavaScript中删除脚本标签即可使用
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.