Does anyone know how to display Rich Text without an iframe (on the web)?
I have an mail-in database; I’d like to display the contents of each email it receives more-or-less as it was sent. That is, I’d like to include inline images, show attachment links etc. Much like the mail database does. My problem is that Domino uses an iframe to do this (and I don’t seem to even be able to change the size of it).
I’m guessing I need to pre-process the message body into a “web friendly” version, but can’t find how the mail database does this. Does anyone have any ideas or examples?
Subject: Displaying Rich Text Fields without an iframe on the web
Are you sure it’s an iframe? I’ve never seen Domino come up with one of those on its own. Check the HTML source. If you’ve got the document open for editing, it might be using tags. If you want it to appear in a formatted fashion, the best thing to do is simply not to open the document for editing. If you must open it for editing, check the properties for the rich text field on the form and have it render the field at an applet rather than as HTML.
Subject: RE: Displaying Rich Text Fields without an iframe on the web
Yes, sadly it’s an iframe. At present, I’m only viewing, so editing is not the problem.
The iframe is created when the body field appears to contain something other than text. For example, if I email into the DB from Notes, no iframe appears, but if I use Exchange to email in, I get an iframe. I put this down to Notes understanding that the Exchange email was in HTML, and so needs “special handling”.
Curiously, and possibly usefully, the document in the iframe is pretty much what I want, except of course I want to “paste” that into the HTML I’ve already got.
If doing the necessary HTML sanity checking is a problem, then I’d settle for being able to change the size of the iframe. I don’t even seem to be able to do that!
Subject: RE: Displaying Rich Text Fields without an iframe on the web
If it is an iframe, it will be accessible through document.getElementsByTagName(‘iframe’)[0] in the browser.
Subject: Solution: Displaying Rich Text Fields without an iframe on the web
I’ve sort of solved this problem.
Notes puts in an iframe if the rich text field contains things like . It does this because otherwise, simply pasting that text into an HTML page would seriously break the rendering by the browser. It’s essentially a safety feature.
To avoid an iframe, I initially tried using a computed value of @text(body), but this loses just about everything useful in the body, so it’s not too useful.
I’ve eventually settled on using an agent. I more or less pinched this from the (extremely good) BlogSphere project at openntf.org. The agent basically removes anything inside angle brackets, so drops all the HTML. It does maintain some of the formatting though. Whilst not perfect, it’s a good start. I hope to tweak it so that it keeps some tags (eg. B, I, H, etc). That way, not too dangerous, and makes pages look nice easily.
Thanks to everyone who gave me suggestions - it certainly got me thinking about it all in a new way.
Subject: RE: Solution: Displaying Rich Text Fields without an iframe on the web
Scrub (most of) that - I’ve got an even better way of doing this particular job.
This code in the agent does a much better job of de-lousing the incoming mail message. It converts it to Notes Rich Text, which renders just fine on the web.
REM This lot stolen from Mail(6) Template. It converts the body field
REM into a Rich Text item, which prints nicely on an HTML page.
Dim rtiEdit As Variant
Dim rtiTmpEdit As New notesrichtextitem( doc, "BodyTemp")
Set rtiEdit = doc.getFirstItem("Body")
Call rtiTmpEdit.appendRTItem( rtiEdit )
Call doc.RemoveItem("bodynohtml")
Dim rtiNewBodyEdit As New notesrichtextitem( doc, "bodynohtml" )
Call rtiNewBodyEdit.appendRTItem(rtiTmpEdit)
Call doc.removeItem( "BodyTemp")
(the nice version of “body” ends up in “bodynohtml”, if you didn’t figure that out!)
Subject: Displaying Rich Text Fields without an iframe on the web
The web server will use an iframe if the html in the mime part contains tags like “body”, “base”, “frameset”, or “html”