Re: How can I access full source of a WebView
Re: How can I access full source of a WebView
- Subject: Re: How can I access full source of a WebView
- From: Rob Keniger <email@hidden>
- Date: Wed, 8 Oct 2008 09:13:52 +1000
On 08/10/2008, at 8:45 AM, Ömer Kardaş wrote:
This works better. However external CSS code is not copied, which
makes the page look different. When I select all and copy from the
webview manualy and then paste it on a new mail window it works
fine, the external CSS is copied as well. Is there any way I get the
full source (including the external CSS) so that I can place it on
the pasteboard?
In order to get the source of a WebView you'd do something like this:
DOMHTMLElement* el=(DOMHTMLElement*)[self
mainFrameDocument].documentElement;
NSString* source=el.outerHTML;
However, external CSS files are not part of the source of the page so
no method of obtaining just the source code will do this for you.
I suspect what is happening when you copy and paste into Mail is that
the WebView is placing a web archive on the clipboard, which contains
all the images and other linked resources.
You can get a web archive like this:
[[[webView mainFrame] dataSource] webArchive];
When copying to the clipboard you can specify the type as
WebArchivePboardType.
--
Rob Keniger
_______________________________________________
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