re-route events in IE (or rich text woes)

J

jceddy

Well, there is something here I'm working on, and I have a problem that
has several possible solutions...none of which I can figure out how to
implement.

Basically, I am creating a rich text editing element, using design mode
in IE, that validates/cleans up the contents of anything that is pasted
into it.

The element that has design mode on is the body of a page nested within
an IFRAME in the main page.

The problem is this: If the user pastes something into the document
using CTRL-V, I am able to detect the paste and go ahead to validate
the new contents of the document. If, however, the user pastes
something into the document by DRAGGING it from another source, there
doesn't seem to be an event that I can capture.

The ondrag/drop events seem to be disabled in IE in designMode, and
when something is being dragged, no mouseover/down/up events fire. The
document body doesn't seem to have an onpaste event that I can capture,
though I have seen this event on other elements.

So...possible solutions?

Is there any way to disallow drag/drop pasting in an element in IE with
design mode turned on?

I could put an "invisible" div over the IFRAME, to control access to
the IFRAME, but then I need a way to re-route the appropriate events
(onmousedown, onmouseup, etc.) to the IFRAME from the invisible
div...anyone know of a way to do that?

I could manually move the cursor, selection, etc., around in the
IFRAME...IF I could figure out a way to move the cursor/change the
selection in an element with designMode on, based on the mouse
position...but I can't seem to figure out a way to do that, either.

I'm going to try embedding a DIV that takes up the whole window in the
IFRAME, and have THAT be the rich text cotnainer, because maybe it will
be easier to capture the onpaste events...we'll see.
 
J

jceddy

OK, looks like I was making it more complicated than need be.

If, instead of setting the designmode of the IFRAME's document to on, I
just include "contenteditable" in the IFRAME document's BODY tag, I can
capture the onpaste events.

It might still be interesting to see if some of the other things I was
trying to do could be done, though...
 
J

jceddy

Heh...so now my code for finding the cursor position doesn't work...

Anyone know a way to detect the position of the insertion point in a
textarea that doesn't involve resetting the innerHTML?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top