问题
We are working on Objective C application for desktop Mac.
We use WebView component to display HTML pages.
When the page is loaded from the local file system, Flash movies are not displayed on the page. As it turned out the problem is not exactly about Flash. Most WebView plugins are missing.
When the page is loaded from the Internet, Flash is displayed properly and there are many plugins available.
The problem does not occur on my Mac, but it happens to 30% of our customers. It is reproduced on MacBook (not MacBook air), Mac OS version is 10.5.8.
Guys, please help us, I have no idea how to tackle this. This is the only obstacle preventing us from the product release.
Why WebView plugins are not available when a local page is loaded?
What can be the source of the problem - Safari configuration, Mac security settings, some software installed?
How can I reproduce the problem on my Mac?
This is our WebView initialization code for local page loading.
IBOutlet WebView* webView;
...
[[webView preferences] setPlugInsEnabled:YES];
WebFrame *mainFrame = [webView mainFrame];
NSString* path = [NSString stringWithFormat:@"%@/page.html",[[NSBundle mainBundle] resourcePath]];
NSURL* url = [NSURL fileURLWithPath:path];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[mainFrame loadRequest:request];
Have you noticed any flaws?
UPDATE 1
Test application
Source code
UPDATE 2
Minimal test, I have left only the code necessary to open the local page. No diagnostic window displayed. Test application, simple
Full source code for Application Delegate of the simple test
#import "WebViewAppDelegate.h"
#import <WebKit/WebView.h>
#import <WebKit/WebFrame.h>
@implementation WebViewAppDelegate
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
[[webView preferences] setPlugInsEnabled:YES];
WebFrame *mainFrame = [webView mainFrame];
NSString* path = [NSString stringWithFormat:@"%@/page.html",[[NSBundle mainBundle] resourcePath]];
NSURL* url = [NSURL fileURLWithPath:path];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[mainFrame loadRequest:request];
}
@end
回答1:
ok,
running v2 from the download failed, I still got the plugins alert and no crab
so I rebuilt the xcode project and included 10.5 as a target, then manually moved the html and swf into contents and it reports all the safari plugins and runs on 10.5.8
so although your plist says 10.5 [min] your sdk target was/is 10.6, so it won't run on 10.5
john
回答2:
your plugins and alert may be blocking your linked js, the crab does not run in your webview here.
I can run the swf in another apps webview by pointing to the html file in package contents and that's without any 'plugins' enabled.
you might try adding WebKitDeveloperExtras booleen true to your prefs file so you can check with webinspector.
回答3:
I ran it in a Google 'SketchUp' WebDialog, the Nib file has the exact option settings as yours. If your unfamiliar with SU it has a Ruby Console available and you can write or serve html files to it. The free version and a little ruby is all that's required. john
来源:https://stackoverflow.com/questions/5855165/mac-os-webview-why-flash-and-other-plugins-are-not-available-when-a-local-page