document.selection.createRange()

Discussion in 'Javascript' started by tylersimon@gmail.com, Oct 9, 2007.

  1. Guest

    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
     
    , Oct 9, 2007
    #1
    1. Advertising

  2. 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>
     
    Thomas 'PointedEars' Lahn, Oct 9, 2007
    #2
    1. Advertising

  3. Guest

    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 <>
    wrote:
    > 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>
     
    , Oct 10, 2007
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Andrew Crowe
    Replies:
    1
    Views:
    4,479
    Andrew Crowe
    Sep 13, 2004
  2. Martin Karlsson
    Replies:
    1
    Views:
    98
  3. lawrence
    Replies:
    7
    Views:
    155
    Thomas 'PointedEars' Lahn
    May 19, 2004
  4. lawrence
    Replies:
    14
    Views:
    241
  5. Martin Nadoll

    document.selection.createRange()

    Martin Nadoll, Apr 20, 2009, in forum: Javascript
    Replies:
    1
    Views:
    370
    Thomas 'PointedEars' Lahn
    Apr 20, 2009
Loading...

Share This Page