On Wednesday, July 2, 2003, at 11:15 AM, Matthew T. Russotto wrote:
Hmm. Well it seems WebKit is really not suitable for much other than
a straight browser.
Why do you draw that conclusion? WebKit is already being used by
applications that are not straight browsers, like Mail, Help Viewer and
Sherlock. The "Picture Browser" sample also demonstrates some very
non-browsery uses of WebKit.
For instance, it doesn't look like you can intercept a click on a link
which points to an anchor in the same document.
Do you have an example that shows you can't? I believe it should work
using the normal policy delegate mechanism to intercept link clicks.
For example, try going to
http://volokh.com/2003_06_29_volokh_archive.html#105717157427042021 and
command-click on one of the orange time links in Safari. Notice that
they are anchor links to the same document, but they will open in a new
window or new tab. Safari achieves this using the policy delegate in
the usual way.
Nor can you scroll to an anchor (other than by navigation).
Scrolling with navigation doesn't really seem like a big deal to me.
After all, who cares if you get a #whatever at the end of the URL if
your app is really that non-browsery?
But if you really want to do it, you can execute JavaScript code to do
it, using the stringByEvaluatingJavaScriptFromString: method. Here's
some JavaScript code that seems to do the right thing:
var anchor = document.anchors["myAnchor"];
window.scrollTo(anchor.offsetLeft, anchor.offsetTop);
You can't really delve into the HTML structure, e.g. to tell where a
particular element is.
It's true that we currently don't have this feature, although again you
can achieve similar things in many cases by executing custom JavaScript
in the document.
Maybe using WebCore directly is a better idea... but there's no
stable API for that, is there?
WebCore has no public API, and in general it's not a good idea to link
to it directly. Maybe if you tell us a bit more about your specific
requirements, we can help you figure out ways to do what you want with
WebKit.