This could be shortened to the more standards-compliant
document.getElementById('frameID').contentDocument.selection.createRange().text
For it to work in Gecko-based browsers, though, it always needed to be
document.getElementById('frameID').contentDocument.getSelection()
which returns the selected text (for highlighted images: the alternative
text) as a string value, or
document.getElementById('frameID').contentWindow.getSelection()
or the more standards-compliant
document.getElementById('frameID').contentDocument.defaultView.getSelection()
which both return a proprietary Selection object.
Recently also supported is the following feature specified in W3C DOM Level
2 Range:
document.getElementById('frameID').contentDocument.createRange().toString()
Your approach has never worked in Firefox as neither the Gecko DOM nor the
W3C DOM support a `selection' property on Document objects; it is MSHTML-
proprietary.
Do not forget to put your question in the message body next time.
PointedEars
--
Prototype.js was written by people who don't know javascript for people
who don't know javascript. People who don't know javascript are not
the best source of advice on designing systems that use javascript.
-- Richard Cornford, cljs, <
[email protected]>