using textrange to stop tr's being selectable

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • foldface@yahoo.co.uk

    using textrange to stop tr's being selectable

    Hi
    I have a table and I've been trying to find a way to stop the text
    in the
    table being selectable.
    One article nearly works for me:



    But not quite. The code below shows my problem:

    <table width=50% border=groove>
    <tr OnMouseDown='On MouseDown()'>
    <td>hi</td>
    </tr>
    </table>

    <script>
    function OnMouseDown() {
    var obj = window.event.sr cElement;
    var r = document.body.c reateTextRange( );
    r.moveToElement Text(obj);
    r.select();
    return true;
    }

    </script>

    This code seems to stop the selection by effectively selecting the
    text before hand, selecting text twice == select/unselect. The problem
    is when you press
    the ctrl key then selecting the text twice == select/select, i.e. it
    stays selected.
    So all I want to do is stop text being selected when the ctrl key is
    pressed,
    any ideas?

    Thanks
    F
  • Thomas 'PointedEars' Lahn

    #2
    Re: using textrange to stop tr's being selectable

    foldface@yahoo. co.uk wrote:[color=blue]
    > [...]
    > any ideas?[/color]

    Why is it that some people think they can mess with
    the program of the user without any disadvantage?


    PointedEars

    Comment

    • foldface@yahoo.co.uk

      #3
      Re: using textrange to stop tr's being selectable

      Thomas 'PointedEars' Lahn <PointedEars@nu rfuerspam.de> wrote in message news:<40B92ACE. 7090608@Pointed Ears.de>...[color=blue]
      > foldface@yahoo. co.uk wrote:[color=green]
      > > [...]
      > > any ideas?[/color]
      >
      > Why is it that some people think they can mess with
      > the program of the user without any disadvantage?
      >
      >
      > PointedEars[/color]

      The users would -never- want to select text in my particular case, I'm not
      doing this to be clever but to workaround an IE idiosyncrasy

      Comment

      • Thomas 'PointedEars' Lahn

        #4
        Re: using textrange to stop tr's being selectable

        foldface@yahoo. co.uk wrote:
        [color=blue]
        > The users would -never- want to select text in my particular case, I'm
        > not doing this to be clever[/color]

        For that would prove the exact opposite.
        [color=blue]
        > but to workaround an IE idiosyncrasy[/color]

        Which is? Maybe you are asking the wrong question.


        PoointedEars

        Comment

        • Thomas 'PointedEars' Lahn

          #5
          Re: using textrange to stop tr's being selectable

          foldface@yahoo. co.uk wrote:
          [color=blue]
          > The users would -never- want to select text in my
          > particular case, I'm not doing this to be clever[/color]

          For what you are doing would prove the exact opposite.
          [color=blue]
          > but to workaround an IE idiosyncrasy[/color]

          Which is? Maybe you are asking the wrong question.


          PointedEars

          Comment

          • Martin Honnen

            #6
            Re: using textrange to stop tr's being selectable



            foldface@yahoo. co.uk wrote:

            [color=blue]
            > I have a table and I've been trying to find a way to stop the text
            > in the
            > table being selectable.[/color]

            For IE/Win you should try whether
            <td onselectstart=" return false;">
            or
            <table onselectstart=" return false;">
            is all you need.
            --

            Martin Honnen


            Comment

            • foldface@yahoo.co.uk

              #7
              Re: using textrange to stop tr's being selectable

              > For IE/Win you should try whether[color=blue]
              > <td onselectstart=" return false;">
              > or
              > <table onselectstart=" return false;">
              > is all you need.[/color]

              it does -exactly- what I want :-)
              Thanks
              F

              Comment

              Working...