document.selection.createRange()

T

tylersimon

Hi,

I am trying to get the current selected text from a document within a
frameset.

In Firefox all works well using getSelection.

In IE createRange is returning me a type of "None". After some
investigation it appears that the fact that this is in another frame
is critical. I am clicking on a custom button (it's a <div> with an
<img> in it) in another frame - just as I do this the selection is
lost. If I replace the custom button with an <input> button then the
selection is not lost.

Is there any way to trap the loss of the selection before it occurs? I
have tried onfocus and onblur in the frameset but these are too late.

Simon
 
T

Thomas 'PointedEars' Lahn

I am trying to get the current selected text from a document within a
frameset.

In Firefox all works well using getSelection.

Which version?
In IE createRange is returning me a type of "None".

Which OS, which version? How is createRange() called?
After some investigation it appears that the fact that this is in another
frame is critical.

If the domains differ, that could be the case.
I am clicking on a custom button (it's a <div> with an <img> in it) in
Eeek.

another frame - just as I do this the selection is lost. If I replace the
custom button with an <input> button then the selection is not lost.

Is there any way to trap the loss of the selection before it occurs? I
have tried onfocus and onblur in the frameset but these are too late.

Before you attempt to cure the symptoms further, show some of your code or
post a URL.

http://jibbering.com/faq/


PointedEars
 
T

tylersimon

I am using Firefox 2.0 on Windows and IE 7.0 on windows.

I cannot use a builtin button as the code is part of a complex web
application and it does not use built in buttons as they cannot be
styled in the way I require.

An example bit of script from some test code is on <img> on click
handler.

<img onClick="f=top.frames['test']; if (f)
{ alert(f.document.selection.createRange().text); }" blah blah>

I have partially solved it by using an onselect handler within the
document and simply remembering the result. Works OK but double click
select does not work.

Simon
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top