0

I have tried in many ways that specified in many threads. Still my WebView not loading the local js files. The way that I have tried

NSString *tempResourcePath=[[NSBundle mainBundle] resourcePath];
NSURL *resourceUrl = [NSURL fileURLWithPath:tempResourcePath];
[webView loadHTMLString:html baseURL:resourceUrl];


NSString *html = [[NSString alloc] initWithContentsOfFile:htmlPath];
    NSString *resourcePath = [[NSBundle mainBundle] resourcePath];
    //resourcePath = [resourcePath stringByReplacingOccurrencesOfString:@"/" withString:@"//"];
    resourcePath = [resourcePath stringByReplacingOccurrencesOfString:@" " withString:@"%20"];
    resourcePath = [NSString stringWithFormat:@"file:/%@/",resourcePath];
 NSURL *resourceUrl = [NSURL fileURLWithPath: resourcePath];

but the webview not working. Could anyone please help me out in fixing this problem?

Manoj Kumar
  • 370
  • 2
  • 6
  • 25

1 Answers1

0

Make sure that the Javascript files are being copied to the resource bundle. When you add .js files to Xcode, it will try to compile them by default, rather than copying them to the resource bundle. See jQuery not loading on the iPhone for details.

Community
  • 1
  • 1
Kristopher Johnson
  • 81,409
  • 55
  • 245
  • 302