469,284 Members | 2,488 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,284 developers. It's quick & easy.

Can you get selected text from a parent?

If I have an iFrame on a webpage, and a user selects text or objects in the
parent of my iFrame, how can I get the selected text or objects properties
from my iFrame child?
Oct 6 '06 #1
2 1867


smerf wrote:
If I have an iFrame on a webpage, and a user selects text or objects in the
parent of my iFrame, how can I get the selected text or objects properties
from my iFrame child?
In general how the browser exposes a text selection to script is highly
browser dependent.
Mozilla and by now Opera 9 expose a selection object per window that you
can access as
if (typeof window.getSelection != 'undefined') {
var selection = window.getSelection();
}
respective for the iframe then
if (window != parent && typeof parent.getSelection != 'undefined') {
var selection = parent.getSelection();
}
One documentation for that selection object is here:
<http://www.xulplanet.com/references/objref/Selection.html>


--

Martin Honnen
http://JavaScript.FAQTs.com/
Oct 6 '06 #2
Sweet! Thanks for the help, Martin.

"Martin Honnen" <ma*******@yahoo.dewrote in message
news:45***********************@newsspool1.arcor-online.net...
>

smerf wrote:
>If I have an iFrame on a webpage, and a user selects text or objects in
the parent of my iFrame, how can I get the selected text or objects
properties from my iFrame child?

In general how the browser exposes a text selection to script is highly
browser dependent.
Mozilla and by now Opera 9 expose a selection object per window that you
can access as
if (typeof window.getSelection != 'undefined') {
var selection = window.getSelection();
}
respective for the iframe then
if (window != parent && typeof parent.getSelection != 'undefined') {
var selection = parent.getSelection();
}
One documentation for that selection object is here:
<http://www.xulplanet.com/references/objref/Selection.html>


--

Martin Honnen
http://JavaScript.FAQTs.com/

Oct 6 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.