Re: Click on a URL in WebKit
Re: Click on a URL in WebKit
- Subject: Re: Click on a URL in WebKit
- From: Rush Manbert <email@hidden>
- Date: Wed, 31 May 2006 10:45:18 -0700
malcom wrote:
Hi list,
I've created using XSL+CSS+HTML a web page. You can see it here:
http://www.malcom-mac.com/files/webkit_test/prova.html
There are two nodes. If you click on each node a javascript try to
loading an http:// address. However it's not a normal web site. I need
to intercept it to load a particular file on the disk with the given
code (url path is the unique code).
I've tried with this into the target WebKit delegate class.
- (void)webView:(WebView *)sender
decidePolicyForNavigationAction:(NSDictionary *)actionInformation
request:(NSURLRequest *)request frame:(WebFrame *)frame
decisionListener:(id<WebPolicyDecisionListener>)listener; {
NSLog(@"POLICY: .%@. %@",[[request URL] scheme],[[request URL] path]);
if (![[[request URL] scheme] isEqualToString:@"http"])
[listener use];
else {
[listener ignore];
NSLog(@"[%@]",[[request URL] path]);
ANTArtNode *art = [_sGroup getArticleNodeForID: [[request URL]
path]];
[self loadArticle: art forGroup: _sGroup];
}
}
However it does not work and nothing will be launched.
Policy nslog returns:
POLICY: .about. (null)
POLICY: .applewebdata.
Why?
Hi Malcom,
This is really a WebKit question (there's a separate list), but I'll
answer here.
Assuming that you really go through the "else" clause, then [listener
ignore]; is the right thing to do. However, what happens next depends on
what your loadArticle method does.
I think you need to do the following:
1) Get the article URL in a NSString. Let's assume this string is names
"articleUrl"
2) Then:
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL
URLWithString:articleUrl]]
[frame loadRequest: request];
(I have paraphrased this from my own code that does the same thing. I
hope I didn't mess up the message formats.)
This should load the new URL. The only thing that I found to be
problematic is that you will come through the
decidePolicyForNavigationAction routine again, so you may need to be
careful about state and keep track of when you're recursing because of a
new load request.
Hope it helps,
Rush
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden