-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed
Description
This isn't a huge deal, but I just wanted to confirm whether anyone has experienced this issue. I'm trying to load dynamically-created HTML in my webView:
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"about:blank"]];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[self.mainFrame loadRequest:request];
[self setEditable:YES];
[self setNeedsDisplay:YES];
NSBundle *webTechBundle = [NSBundle bundleWithPath:[[NSBundle mainBundle]
pathForResource:@"MyWebTechBundle"
ofType:@"bundle"]];
NSMutableArray *scripts = @[@"js1.js", @"js2.js", @"js3.js"].mutableCopy;
for (NSString *script in scripts.copy) {
NSString *filePath = [webTechBundle pathForResource:[script stringByDeletingPathExtension] ofType:script.pathExtension];
NSString *fileContents = [NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:nil];
[scripts replaceObjectAtIndex:[scripts indexOfObject:script] withObject:fileContents];
}
[self.windowScriptObject evaluateWebScript:[scripts componentsJoinedByString:@";"]];
self.webViewbridge = [WebViewJavascriptBridge bridgeForWebView:self handler:^(id data, WVJBResponseCallback responseCallback) {
NSLog(@"from DOM: %@", data);
}];
Whatever I do to dynamically load scripts, WBJB never works. It only seems to work with pre-defined html files. Has any testing been done with windowScriptObject?
Metadata
Metadata
Assignees
Labels
No labels