Perhaps this is similar to this question, which has no responses: loadHTMLString Not Working With iOS5?
I have a UIWebView which I populate using loadHTMLString:baseURL
I'm not an HTML standards expert, but...did you try to close the <script>
tag:
<script type="text/javascript" src="./myscript.js"></script>
It worked for me.
The way to load an HTML file that contains embedded folder references, such as '/file.js', is to load it as a URL rather than as a STRING.
NSString *urlAddress = [[NSBundle mainBundle] pathForResource:@"index" ofType:@"htm"];
NSURL *url = [NSURL fileURLWithPath:urlAddress];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
[webView loadRequest:requestObj];
I use this along with referenced folders (not referenced files) to create an ordinary website structure in Xcode, with js/ and css/ and images/ references in the embedded index.htm file, e.g.
<script type="text/javascript" src="js/jquery-1.6.4.min.js"></script>
UPDATE
I don't think that referencing a URI within a loaded HTML string was officially supported. If you must use a string, then load the needed resource files into the string before you load it into the UIWebView.