By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,377 Members | 1,706 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,377 IT Pros & Developers. It's quick & easy.

Can you get selected text from a parent?

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a


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

P: n/a
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.