How to find selection in HTML document that contains iframe or just frames
问题 Is there a way to find the selected text in an HTML document if the text may be within one of its frames (or iframes)? If the document has no frames it's simple: var text; if (document.getSelection) { // Firefox and friends text = document.getSelection(); } else if (document.selection) { // IE text = document.selection.createRange(); } if (text == undefined || text == '') { // Iterate over all textarea elements and see if one of them has selection var areas = document.getElementsByTagName(