• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: How can I access full source of a WebView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How can I access full source of a WebView


  • Subject: Re: How can I access full source of a WebView
  • From: Ömer Kardaş <email@hidden>
  • Date: Wed, 08 Oct 2008 02:44:42 +0300

Thanks Rob,

I tried your way (DOMHTMLElement* el...) and it gave me the source. Unfortunatly it gives only source and does not include external files.

I already tried your second approach.
[pb setData:[[[myWebView mainFrameDocument] webArchive] data] forType:WebArchivePboardType];


I just found something intereting. I was wrong to think that the external CSS is not copied in this way. I saved the Pasteboard as webarchive, opened it from Safari, and looked at the source. CSS was not there. On the contrary, webarchive produced by manual copy had the CSS code. But then, I opened the webarhives as TEXT (using subethaedit). The CSS code was PRESENT in BOTH of the WebArchive files. Somehow Safari can not see the one produced by the above code.

Any other suggestions?

On Oct 8, 2008, at 2:13 AM, Rob Keniger wrote:


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

_______________________________________________

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


References: 
 >How can I access full source of a WebView (From: Ömer Kardaş <email@hidden>)
 >Re: How can I access full source of a WebView (From: Rob Keniger <email@hidden>)

  • Prev by Date: Re: Trouble with NSSplitView
  • Next by Date: Re: Trouble with NSSplitView
  • Previous by thread: Re: How can I access full source of a WebView
  • Next by thread: Bottombar appearance
  • Index(es):
    • Date
    • Thread