In my application, i am using WebView to display the content, Now is it possible to modify the content dynamically, the requirement is something like this,
i will g
Never Mind
Solved it by this way
In AwakeFromNib Method, added following code,
-(void)awakeFromNib{
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"about:blank"]];
//URL Requst Object
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
//Load the request in the UIWebView.
[[pWebView mainFrame ]loadRequest:requestObj];
[pWebView setEditable:YES];
[pWebView setNeedsDisplay:YES];
}
and added this function to append the body element,
-(void)appendTagToBody:(NSString *)tagName InnerHTML:(NSString *)innerHTML
{
// Gets a list of all <body></body> nodes.
DOMNodeList *bodyNodeList = [[[pWebView mainFrame] DOMDocument] getElementsByTagName:@"body"];
// There should be just one in valid HTML, so get the first DOMElement.
DOMHTMLElement *bodyNode = (DOMHTMLElement *) [bodyNodeList item:0];
// Create a new element, with a tag name.
DOMHTMLElement *newNode = (DOMHTMLElement *) [[[pWebView mainFrame] DOMDocument] createElement:tagName];
// Add the innerHTML for the new element.
[newNode setInnerHTML:innerHTML];
// Add the new element to the bodyNode as the last child.
[bodyNode appendChild:newNode];
}
and whenever wanted to change the content,
-(void)appendString:(NSString *)pString{
[self appendTagToBody:@"div" InnerHTML:@"<div><p> Hi there </p></div>"];
[self setNeedsDisplay:YES];
}