سؤال

The following code alerts a message with the text selected on the current page, if viewing with chrome at least:

alert(window.getSelection());

But how can I get this to work even when the selection is text that is inside an iFrame? (the iFrame contents is of the same domain)

هل كانت مفيدة؟

المحلول

this should work:

document.getElementById('iframe_id').contentWindow.getSelection();
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top