Reputation: 1397
I am using GWT. I have a string which consists of all the HTML for an HTML email, which has some css styles for that email, such as links as green.
I want to display that email inside my GWT app, but when I use the HTML widget and add the HTML I end up changing the CSS styles of the whole page, for example all my links change color to what is specfied in the email.
It seems like I want to use an iframe, but I can't point it to a different URL, instead I want to use the string that I have and fill the HTML of it.
Upvotes: 1
Views: 892
Reputation: 546
You can do it like described here: http://bealetech.com/blog/2010/01/25/embedding-html-document-in-an-iframe-with-gwt/
As a reference this is a short summary:
Create an an IFrameElement.
IFrameElement iframe = Document.get().createIFrameElement();
And add it to your page.
Then write the contents of the HTML mail to this element using a native function like this:
private final native void fillIframe(IFrameElement iframe, String content) {
var doc = iframe.document;
if(iframe.contentDocument)
doc = iframe.contentDocument; // For NS6
else if(iframe.contentWindow)
doc = iframe.contentWindow.document; // For IE5.5 and IE6
// Put the content in the iframe
doc.open();
doc.writeln(content);
doc.close();
};
Upvotes: 1