Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: creating a dom



How do I create a dom? Or more specifically, how do I add dom nodes to a web view? I'm guessing I need to add them to a DOMDocument. Then how do I add that DOMDocument to a WebView so that it displays it as HTML?

Something like:

[webview setFrameLoadDelegate:delegate];
[[webview mainFrame] loadHTMLString:@"<html><body style='border: 0; margin: 0; padding: 0'></body></html>" baseURL:nil];


where delegate is an instance of some class of yours. In the delegate you implement webView:didFinishLoadForFrame: and do something like:

- (void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *) frame
{
DOMDocument *doc = [[sender mainFrame] DOMDocument];
DOMNodeList *list = [doc getElementsByTagName:@"BODY"];
assert([list length] > 0);
DOMNode *body = [list item:0];
DOMElement *el = [doc createElement:@"P"];
[body appendChild:el];
[el appendChild:[doc createTextNode:@"this text has been added via DOM manipulation"]];
}


Hope this helps!

Duncan

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webkitsdk-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webkitsdk-dev/email@hidden

This email sent to email@hidden
References: 
 >creating a dom (From: Michael Hanna <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.