I'm currently working with code that looks something like this:
try {
// IE ONLY
var theElement = "myElementName";
window.frames[theElement].focus();
var selection = window.frames[theElement].document.selection.createRange();
alert ( selection.htmlText );
} catch(e) {
var selection = window.frames[theElement].document.getSelection();
alert ( selection );
}
As you can see, I'm accessing a node from an iframe (which is already challenging). I'm stepping into uncharted territory here, so I'm sure there are more challenges ahead. Right now, my main goal is to achieve the same result in Firefox as in IE.
In IE, I can retrieve the HTML code of the selection using the (presumably IE-only) htmlText property of the object returned by createRange(). I'm searching for the Firefox equivalent of that (or a function that can provide me with a similar outcome).
Does anyone have any insights on how to accomplish this?