WebKit and saving position through a reload
WebKit and saving position through a reload
- Subject: WebKit and saving position through a reload
- From: Lawrence Cabusora <email@hidden>
- Date: Tue, 6 Jul 2004 13:16:24 -0400
Hi,
Inspired by the live-updating HTML display that SubEthaEdit offers, I
was trying to throw a similar feature into my home-grown blogging
program. Basically, I have a regular old NSTextView in which one edits
the plaintext of a blog entry; by listening for the notification
"NSTextDidChangeNotification", my plaintext->HTML parser converts the
blog entry into a valid HTML webpage held in an NSString; let's call it
"theHTMLString". (I know this is a little inefficient, as it re-parses
the entire blog entry for every single keypress, but it is more than
fast enough for my purposes, what with the small amounts of text I'm
dealing with. Anyway, that is another issue entirely.)
To get the live WebKit display, I added a WebView to my window, then
had my program make something like the following call every time the
blog plaintext changes:
[[myWebView mainFrame] loadHTMLString:theHTMLString baseURL:[NSURL
URLWithString:@""]];
This works just fine; the WebView updates real-time along with my
changes to the blog plaintext.
My problem is this: Because the WebView/WebFrame/whatever loads a new
string every time there is a change, the view defaults to the top of
the page with every keypress. This is not the same behavior as, say,
hitting the "Reload" button in Safari; there, Safari appears to
(usually) try to retain the same approximate view position in the
webpage, instead of going back to the top. This behavior is what I
would like to emulate, but I am not well-versed in the vagaries of
WebKit, and I really have no idea how I would go about doing that.
Ideas? Any would be appreciated, thanks in advance.
-----
Lawrence / ( @ |_
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.