Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > document.selection.createRange()

Reply
Thread Tools

document.selection.createRange()

 
 
tylersimon@gmail.com
Guest
Posts: n/a
 
      10-09-2007

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

 
Reply With Quote
 
 
 
 
Thomas 'PointedEars' Lahn
Guest
Posts: n/a
 
      10-09-2007
wrote:
> 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.


What is your "custom button" exactly? Why do you consider an "<input>
button" not to be custom(izable)?

> 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
--
"Use any version of Microsoft Frontpage to create your site. (This won't
prevent people from viewing your source, but no one will want to steal it.)"
-- from <http://www.vortex-webdesign.com/help/hidesource.htm>
 
Reply With Quote
 
 
 
 
tylersimon@gmail.com
Guest
Posts: n/a
 
      10-10-2007

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

On Oct 9, 4:50 pm, Thomas 'PointedEars' Lahn <PointedE...@web.de>
wrote:
> tylersi...@gmail.com wrote:
> > 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.

>
> What is your "custom button" exactly? Why do you consider an "<input>
> button" not to be custom(izable)?
>
> > 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
> --
> "Use any version of Microsoft Frontpage to create your site. (This won't
> prevent people from viewing your source, but no one will want to steal it.)"
> -- from <http://www.vortex-webdesign.com/help/hidesource.htm>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off




Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57