user1648360
user1648360

Reputation:

JavaScript with iphone

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

Upvotes: 0

Views: 87

Answers (3)

user1648360
user1648360

Reputation:

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

Upvotes: 0

Nancy
Nancy

Reputation: 36

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]]];
}

Upvotes: 0

Ravi Kumar
Ravi Kumar

Reputation: 226

Standard way is

<script type="text/javascript" charset="utf-8" src="YourJSPath"></script>

Upvotes: 1

Related Questions