Hey all,
I have HTML file that uses a javascript file. Something in the javascript file is effected by app its self. I need a way to change a variable in that javascript file.
I have been trying this code which loads my HTML file and runs a line of javascript.
Code:
NSString *htmlFile = [[NSBundle mainBundle] pathForResource:@"index" ofType:@"html" inDirectory:@"htmlFolder"];
NSData *htmlData = [NSData dataWithContentsOfFile:htmlFile];
[webView loadData:htmlData MIMEType:@"text/html" textEncodingName:@"UTF-8" baseURL:[NSURL URLWithString:@""]];
NSString* script = [NSString stringWithFormat:@"directory = \"%@\";", documentsDirectory];
[webView stringByEvaluatingJavaScriptFromString:script];
But the variable in the javascript is not changing. directory is delcared at the top of the file. I believe it is a global var. I think the problem is I have not declared which file to run the script in and I do not know how to do that.
If anyone knows how to do it or if there is another solution I would be greatful.
Thanks
Clinton