I have a webview in a desktop app, and I have loaded my html file. In the head of the html file, I link to javascript files, but it only works when those are remote files, I want it to work for other files in the resources folder. What is the path I should use? Is there some issue I am missing?
HTML:
<head>
<meta charset="utf-8" />
<title>MyWebPage</title>
<!-- this works -->
<script type='text/javascript' src="http://somewhereontheweb.com/jquery-1.6.2.min.js"></script>
<!-- this does not -->
<script type='text/javascript' src="jquery-1.6.2.min.js"></script>
<!-- this does not -->
<script type='text/javascript' src="./jquery-1.6.2.min.js"></script>
<!-- this does not -->
<script type='text/javascript' src="./Resources/jquery-1.6.2.min.js"></script>
...
My objective-c code for the webview in case it is relevant:
- (void)webView:(WebView *)aWebView
decidePolicyForNavigationAction:(NSDictionary *)actionInformation
request:(NSURLRequest *)request
frame:(WebFrame *)frame
decisionListener:(id < WebPolicyDecisionListener >)listener
{
if ([self requestIsLinkClick:actionInformation]) {
if ([@"method" isEqual:[[request URL] scheme]]) {
SEL selector = NSSelectorFromString([[request URL] resourceSpecifier]);
if ([prototypeDelegate respondsToSelector:selector]) {
[prototypeDelegate performSelector:selector];
}
}
// [listener ignore];
} // else {
[listener use];
//}
}
I’ve made a class for this purpose, surf here https://github.com/iStopped/iOS-Classes and go in SimpleWebView folder 😉 but before read the readme 😉