Hello,
I need to insert html code - an entire page beginning with the <HTML> tag -
in an empty document (about:blank or a temporary file).
So I try to use htmldoc->Write("<HTML> ... </HTML>"); but when executed,
this line make the app. crash.
Im using the exemple of the embedded mozilla control (PPBrowser.mcp).
Here's what I tried:
CBrowserWindow *theWindow =
CBrowserWindow::CreateWindow(nsIWebBrowserChrome::CHROME_DEFAULT, -1, -1);
ThrowIfNil_(theWindow);
theWindow->SetSizeToContent(false);
theWindow->GetBrowserShell()->LoadURL(nsDependentCString("about:blank"));
// --- My code :
nsCOMPtr<nsIDOMWindow> window;
nsCOMPtr<nsIDOMDocument> doc;
nsCOMPtr<nsIWebBrowser> browser;
theWindow->GetBrowserShell()->GetWebBrowser(getter_AddRefs(browser));
browser->GetContentDOMWindow(getter_AddRefs(window));
window->GetDocument(getter_AddRefs(doc));
nsCOMPtr<nsIDOMHTMLDocument> htmldoc(do_QueryInterface(doc));
htmldoc->SetTitle(NS_LITERAL_STRING("My doc")); // pass
htmldoc->Open(); // pass
htmldoc->Write(NS_LITERAL_STRING("<HTML><BODY><P>My
document</BODY></HTML>")); // crash
htmldoc->Close();
theWindow->GetBrowserShell()->Reload();
Can you help me please?
(Im on Mac).
Thanks.