I have a iOS app to load a html string which refer to external css file and javascript file in the same directory.
Here is my html file:
&l
This question is a bit old, but since it has not been answered, I would like to point out that if you would like your web view to load a javascript file residing in your bundle, the way to do it is:
[webView loadHTMLString:html
baseURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] bundlePath]]];
If you don't specify the baseURL there is no chance that the javascript file is loaded.
like the others have said
use baseURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] bundlePath]]];
copy Bundle Resources and not in Compile Resources.
thats it!
By default, xcode will put new Javascript files in Compile Resources instead of Bundle Resources. Click on your project, then on your target. Under 'Build Phases' you may see the Javascript files under 'Compile Sources'. Drag them to down to 'Copy Bundle Resources'.