Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Calling Javascript from WebKit Plugin



I'm trying to learn how to make plugins for WebKit apps, namely
Safari.  Using the WebKitMoviePlugin example from here as a starting
point:

http://developer.apple.com/documentation/InternetWeb/Conceptual/WebKit_PluginProgTopic/Tasks/WebKitPlugins.html

Then I want to trigger a javascript method, I added the js to the page
but am struggling with how to call this.  I added a few lines noted by
a comment below.  It's pretty basic but so far I've utterly failed at
get access to the WebView's scripting environment.  Help!  I'm a bit
of a Cocoa newbie and a total WebKit newbie.

- (void)webPlugInStart
{
    if (!_loadedMovie) {
        _loadedMovie = YES;
        NSDictionary *webPluginAttributesObj = [_arguments
objectForKey:WebPlugInAttributesKey];
        NSString *URLString = [webPluginAttributesObj objectForKey:@"src"];
		
		// added these lines before the if statement
		NSDictionary *webPluginContainerKey = [_arguments
objectForKey:WebPlugInContainerKey];
		myWebView = [[webPluginContainerKey webFrame] webView];
		[myWebView evaluateWebScript:@"pluginLaunchSuccess()"];
		
        if (URLString != nil && [URLString length] != 0) {
            NSURL *baseURL = [_arguments objectForKey:WebPlugInBaseURLKey];
            NSURL *URL = [NSURL URLWithString:URLString relativeToURL:baseURL];
            NSMovie *movie = [[NSMovie alloc] initWithURL:URL byReference:NO];
            [self setMovie:movie];
            [movie release];
        }
    }

    [self start:self];
}
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webkitsdk-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webkitsdk-dev/email@hidden

This email sent to email@hidden



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.