Re: WebView setDownloadDelegate: issue
Re: WebView setDownloadDelegate: issue
- Subject: Re: WebView setDownloadDelegate: issue
- From: Jeff Johnson <email@hidden>
- Date: Fri, 24 Apr 2009 13:31:03 -0500
Hi Mikkel.
The Webkitsdk-dev list would probably be better for this question.
Having said that, does your webview also have a UIDelegate? I ask
because many downloads try to open a new window, so I'm wondering if
webView:createWebViewWithRequest: would be called, for example. If you
don't implement that delegate method, I believe that it just doesn't
create a new webview, which would explain why the download fails.
-Jeff
On Apr 24, 2009, at 5:29 AM, Mikkel Eriksen wrote:
Hi foks
Hopefully the right place to ask this question.
In the project I'm working on, I have a webview that's going to a
specific site. When the user downloads files from that site, I want to
intercept them (basically grab the URL, get the file and parse the
contents).
So in my controller class I have
IBOutlet WebView *webview; //in controller.h
//and
[webview setDownloadDelegate:self]; //in the controller awakeFromNib
//I also took this from Hillegass' book to get a feel for how
downloads work (what delegate methods are called and when):
- (BOOL)respondsToSelector:(SEL)aSelector
{
NSString *methodName = NSStringFromSelector(aSelector);
NSLog(@"respondsToSelector: %@", methodName);
return [super respondsToSelector:aSelector];
}
Now that works with a sampling of random sites I went to:
2009-04-23 22:01:41.122 AO[42395:10b] respondsToSelector:
downloadDidBegin:
2009-04-23 22:01:41.124 AO[42395:10b] respondsToSelector:
download:willSendRequest:redirectResponse:
2009-04-23 22:01:41.458 AO[42395:10b] respondsToSelector:
download:didReceiveResponse:
2009-04-23 22:01:41.460 AO[42395:10b] respondsToSelector:
download:didReceiveDataOfLength:
2009-04-23 22:01:41.569 AO[42395:10b] respondsToSelector:
download:didReceiveDataOfLength:
2009-04-23 22:01:41.983 AO[42395:10b] respondsToSelector:
download:decideDestinationWithSuggestedFilename:
2009-04-23 22:01:41.985 AO[42395:10b] respondsToSelector:
download:didCreateDestination:
etc
But with the specific links on that site, it did not work. No delegate
methods were called.
The problem as far as I can guess is that the links are actually
javascripts that fill out values in a form and submits it to the
server, which then spits out the file. Is there a clean way to
intercept these files?
Regards,
Mikkel
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden