Re: Re: Click on a URL in WebKit
Re: Re: Click on a URL in WebKit
- Subject: Re: Re: Click on a URL in WebKit
- From: malcom <email@hidden>
- Date: Thu, 1 Jun 2006 16:09:08 +0200
loadArticle method need to take the URL string and
1- take the article data from a file inside the hard disk
2- make an html page on it
3- call articledata_webview loadHTMLString method to load the data
about the article
But when you click one of these nodes
(http://www.malcom-mac.com/files/webkit_test/prova.html) nothing will
happend and this method will never called. Instead it will be called
at the first time aftter awakeFromNib. Why?
In fact the code itself is pretty simple.
I've pasted it here:
http://pastebin.com/751330
I really don't know how to intercept these links and make other things
rather than load a standard html page.thanks
malcom
On 5/31/06, Rush Manbert <email@hidden> wrote:
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
--
www.malcom-mac.com - indipendent software developer
mail: email@hidden
_______________________________________________
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