0

I have a big problem I work with HTML and JavaScript in WebView in my program. And everything seems to be nothing but he sees a Java script when I set the path to it

But if everyone in the javascript to put in html all working

Q: How do I properly set the path to the file javascript

I found a solution. It's simple. My JavaScript file was in the wrong format. If you make it in UTF-8 all stand on the place And it's really easy to add

  • Are you asking how the ` – Thilo Sep 28 '12 at 10:30
  • Possibly the same as this issue: http://stackoverflow.com/questions/843820/iphone-uiwebview-local-resources-using-javascript-and-handling-onorientationchan – jonvuri Sep 28 '12 at 10:32

3 Answers3

1

Standard way is

<script type="text/javascript" charset="utf-8" src="YourJSPath"></script>
Ravi Kumar
  • 226
  • 2
  • 10
  • This is correct, connected my java script on the WebView, but he refuses to turn it on –  Sep 28 '12 at 20:51
  • "Kiyura" prompted one of the options, because he truly is working, but my java script is huge, not very much like to insert it so I would like to link –  Sep 28 '12 at 20:55
0
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"file_name" ofType:@"file_type"];  
NSData *data = [NSData dataWithContentsOfFile:filePath];  
if (data) {  
  NSBundle *bundle = [NSBundle mainBundle]; 
  NSString *path = [bundle bundlePath];
  NSString *fullPath = [NSBundle pathForResource:@"file_name" ofType:@"file_type" inDirectory:path];
  [webView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:fullPath]]];
}
Nancy
  • 36
  • 1
0

and so, I fix this error. It was the fact that was written in Javascript Foreman not UTF-8 as I understand xCode only supports UTF-8