textDecorationLineThrough style property (DHTML) in Javascript

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • mary zelinski

    #1

    textDecorationLineThrough style property (DHTML) in Javascript

    I have a word bank for a javascript crossword puzzle I'm working on. What I
    want to do is when a user clicks on a word in the word bank, it crosses
    itself out. I have tried:

    <a href="javascrip t:this.style.te xtDecorationLin eThrough">text here</a>

    to no avail. does anyone have an idea on how to do this?


  • Keith Bowes

    #2
    Re: textDecorationL ineThrough style property (DHTML) in Javascript

    mary zelinski wrote:[color=blue]
    > I have a word bank for a javascript crossword puzzle I'm working on. What I
    > want to do is when a user clicks on a word in the word bank, it crosses
    > itself out. I have tried:
    >
    > <a href="javascrip t:this.style.te xtDecorationLin eThrough">text here</a>
    >
    > to no avail. does anyone have an idea on how to do this?
    >[/color]

    Element.style.t extDecoration = 'line-through'


    Comment

    • Vjekoslav Begovic

      #3
      Re: textDecorationL ineThrough style property (DHTML) in Javascript

      "mary zelinski" <murphysoutlaw@ verizon.net> wrote in message
      news:Ai8%a.23$N 37.4@nwrdny02.g nilink.net...[color=blue]
      > I have a word bank for a javascript crossword puzzle I'm working on. What[/color]
      I[color=blue]
      > want to do is when a user clicks on a word in the word bank, it crosses
      > itself out. I have tried:
      >
      > <a href="javascrip t:this.style.te xtDecorationLin eThrough">text here</a>
      >
      > to no avail. does anyone have an idea on how to do this?[/color]

      <a href="#" onclick="this.s tyle.textDecora tion='line-through';return
      false;">text here</a>,

      but you should consider not using anchor tag if there is no href attribute.


      Comment

      • mary zelinski

        #4
        Re: textDecorationL ineThrough style property (DHTML) in Javascript

        If I shouldn't use an anchor, then how should I do it? Also, I should have
        mentioned before, when it is struck-out, and the user clicks again, I want
        it back to normal. I guess each word could have its own function, but that
        would be a pain.

        Is there any way to do something like this?

        <a href="javascrip t:strike()" id="word1">

        and have the strike function be something like this?

        referred_id.sty le.textDecorati on="line-through"

        the only problem is, how do I get the script to know which id referred it to
        the function? "referred_i d" above in this example would be "word1" . I
        think I've finally found something that you CAN'T do in DHTML.

        "Vjekoslav Begovic" <vjbegovic@inet .hr> wrote in message
        news:bhjiqn$9nq $1@sunce.iskon. hr...[color=blue]
        > "mary zelinski" <murphysoutlaw@ verizon.net> wrote in message
        > news:Ai8%a.23$N 37.4@nwrdny02.g nilink.net...[color=green]
        > > I have a word bank for a javascript crossword puzzle I'm working on.[/color][/color]
        What[color=blue]
        > I[color=green]
        > > want to do is when a user clicks on a word in the word bank, it crosses
        > > itself out. I have tried:
        > >
        > > <a href="javascrip t:this.style.te xtDecorationLin eThrough">text here</a>
        > >
        > > to no avail. does anyone have an idea on how to do this?[/color]
        >
        > <a href="#" onclick="this.s tyle.textDecora tion='line-through';return
        > false;">text here</a>,
        >
        > but you should consider not using anchor tag if there is no href[/color]
        attribute.[color=blue]
        >
        >[/color]


        Comment

        • Vjekoslav Begovic

          #5
          Re: textDecorationL ineThrough style property (DHTML) in Javascript

          "mary zelinski" <murphysoutlaw@ verizon.net> wrote in message
          news:7Bh%a.1376 $N37.1184@nwrdn y02.gnilink.net ...[color=blue]
          > If I shouldn't use an anchor, then how should I do it? Also, I should[/color]
          have[color=blue]
          > mentioned before, when it is struck-out, and the user clicks again, I want
          > it back to normal. I guess each word could have its own function, but[/color]
          that[color=blue]
          > would be a pain.
          >
          > Is there any way to do something like this?
          >
          > <a href="javascrip t:strike()" id="word1">
          >
          > and have the strike function be something like this?
          >
          > referred_id.sty le.textDecorati on="line-through"
          >
          > the only problem is, how do I get the script to know which id referred it[/color]
          to[color=blue]
          > the function? "referred_i d" above in this example would be "word1" . I
          > think I've finally found something that you CAN'T do in DHTML.[/color]

          How about this?
          <html>
          <head>
          <script type="text/javascript">
          function strikeInOut(ele m){
          elem.style.text Decoration = (elem.style.tex tDecoration ==
          'line-through')?'none ':'line-through';
          }
          </script>
          </head>
          <body>
          <a href="#" onclick="strike InOut(this);ret urn false">word1</a><br>
          <a href="#" onclick="strike InOut(this);ret urn false">word2</a><br>
          </body>
          </html>


          Comment

          • Lasse Reichstein Nielsen

            #6
            Re: textDecorationL ineThrough style property (DHTML) in Javascript

            "mary zelinski" <murphysoutlaw@ verizon.net> writes:
            [color=blue]
            > If I shouldn't use an anchor, then how should I do it? Also, I should have
            > mentioned before, when it is struck-out, and the user clicks again, I want
            > it back to normal. I guess each word could have its own function, but that
            > would be a pain.
            >
            > Is there any way to do something like this?
            >
            > <a href="javascrip t:strike()" id="word1">[/color]

            You shouldn't use the "javascript :" pseudo protocol, but yes, you can
            do it.
            <URL:http://jibbering.com/faq/#FAQ4_24>
            [color=blue]
            > and have the strike function be something like this?
            >
            > referred_id.sty le.textDecorati on="line-through"[/color]

            <script type="text/javascript">
            function strike(element) {
            element.strikeS tate = !element.strike State;
            element.style.t extDecoration= element.strikeS tate?"line-through":"none" ;
            }
            </script>

            <a href="" onclick="strike (this);return false">text here</a>

            But again, if you don't have an value for href, you shouldn't be
            saying that what you have is an anchor.

            Alternatives are:
            buttons <button type="button" onclick="strike (this)">text here</button>
            - but it doesn't work in, e.g., NS4.
            spans <span class="clickare a" onclick="strike (this)">text here</span>
            - if you want special styling of the span, use CSS for it. E.g.
            <style type="text/css">
            .clickarea{
            cursor:pointer;
            color:red;
            }
            </style>

            [color=blue]
            > the only problem is, how do I get the script to know which id referred it to
            > the function? "referred_i d" above in this example would be "word1" . I
            > think I've finally found something that you CAN'T do in DHTML.[/color]

            You could pass the id of the element to the function and have the function
            find the element using document.getEle mentById, but it is easier to just
            pass the element itself using the "this" keyword.

            /L 'please don't top post'
            --
            Lasse Reichstein Nielsen - lrn@hotpop.com
            Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit. html>
            'Faith without judgement merely degrades the spirit divine.'

            Comment

            • mary zelinski

              #7
              Re: textDecorationL ineThrough style property (DHTML) in Javascript


              "Lasse Reichstein Nielsen" <lrn@hotpop.com > wrote in message
              news:d6f6aq3z.f sf@hotpop.com.. .[color=blue]
              > "mary zelinski" <murphysoutlaw@ verizon.net> writes:
              >[color=green]
              > > If I shouldn't use an anchor, then how should I do it? Also, I should[/color][/color]
              have[color=blue][color=green]
              > > mentioned before, when it is struck-out, and the user clicks again, I[/color][/color]
              want[color=blue][color=green]
              > > it back to normal. I guess each word could have its own function, but[/color][/color]
              that[color=blue][color=green]
              > > would be a pain.
              > >
              > > Is there any way to do something like this?
              > >
              > > <a href="javascrip t:strike()" id="word1">[/color]
              >
              > You shouldn't use the "javascript :" pseudo protocol, but yes, you can
              > do it.
              > <URL:http://jibbering.com/faq/#FAQ4_24>
              >[color=green]
              > > and have the strike function be something like this?
              > >
              > > referred_id.sty le.textDecorati on="line-through"[/color]
              >
              > <script type="text/javascript">
              > function strike(element) {
              > element.strikeS tate = !element.strike State;
              > element.style.t extDecoration=[/color]
              element.strikeS tate?"line-through":"none" ;[color=blue]
              > }
              > </script>
              >
              > <a href="" onclick="strike (this);return false">text here</a>
              >
              > But again, if you don't have an value for href, you shouldn't be
              > saying that what you have is an anchor.
              >
              > Alternatives are:
              > buttons <button type="button" onclick="strike (this)">text here</button>
              > - but it doesn't work in, e.g., NS4.
              > spans <span class="clickare a" onclick="strike (this)">text here</span>
              > - if you want special styling of the span, use CSS for it. E.g.
              > <style type="text/css">
              > .clickarea{
              > cursor:pointer;
              > color:red;
              > }
              > </style>
              >
              >[color=green]
              > > the only problem is, how do I get the script to know which id referred[/color][/color]
              it to[color=blue][color=green]
              > > the function? "referred_i d" above in this example would be "word1" . I
              > > think I've finally found something that you CAN'T do in DHTML.[/color]
              >
              > You could pass the id of the element to the function and have the function
              > find the element using document.getEle mentById, but it is easier to just
              > pass the element itself using the "this" keyword.
              >
              > /L 'please don't top post'
              > --
              > Lasse Reichstein Nielsen - lrn@hotpop.com
              > Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit. html>
              > 'Faith without judgement merely degrades the spirit divine.'[/color]

              sorry about the top-posting.

              Thanks to all who've helped. I guess my best option is the one Vjekoslav
              Begovic suggested. My knowledge of javascript is only so advanced. I
              would've never thought of that. :) Thanks you all.

              James



              Comment

              Working...