help with quotes, please...

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Aaron Fude

    #1

    help with quotes, please...

    I have this

    <img src="a.jpg" onClick=this.sr c="b.jpg\"">

    and it works. But I like obeying rules so I change it to

    <img src="a.jpg" onClick="this.s rc=\"b.jpg\"">

    and it no longer works.

    Please note that I really cannot do the alternating
    single-quote-double-quote thing is the onClick action is set programatically
    and it is hard to detect exactly what's inside.

    Thanks!

    Aaron Fude


  • Evertjan.

    #2
    Re: help with quotes, please...

    Aaron Fude wrote on 27 okt 2004 in comp.lang.javas cript:
    [color=blue]
    > I have this
    >
    > <img src="a.jpg" onClick=this.sr c="b.jpg\"">
    >
    > and it works. But I like obeying rules so I change it to
    >
    > <img src="a.jpg" onClick="this.s rc=\"b.jpg\"">
    >
    > and it no longer works.[/color]

    <img src="a.jpg" onClick="this.s rc=b.jpg;">

    as long as you do not use spaces in the second jpg name

    ======== or =======

    <script>
    function myB(x){ x.src="b with spaces.jpg"};
    </script>

    <img src="a.jpg" onClick="myB(th is);">

    =============== =====
    [color=blue]
    > Please note that I really cannot do the alternating
    > single-quote-double-quote thing is[as?] the onClick action is set
    > programatically and it is hard to detect exactly what's inside.[/color]

    That does not seem a valid statement, if you can enter \" you can enter
    an apostrophe/single quote programmaticall y too.


    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress,
    but let us keep the discussions in the newsgroup)

    Comment

    • Michael Winter

      #3
      Re: help with quotes, please...

      On 27 Oct 2004 08:21:25 GMT, Evertjan. <exjxw.hannivoo rt@interxnl.net >
      wrote:
      [color=blue]
      > Aaron Fude wrote on 27 okt 2004 in comp.lang.javas cript:
      >[color=green]
      >> I have this
      >>
      >> <img src="a.jpg" onClick=this.sr c="b.jpg\"">
      >>
      >> and it works. But I like obeying rules so I change it to
      >>
      >> <img src="a.jpg" onClick="this.s rc=\"b.jpg\"">
      >>
      >> and it no longer works.[/color][/color]

      It wouldn't. HTML doesn't respect backslash as an escape character. It
      literally sees \" and interprets it as the end of the attribute. Either
      you use single quotes, or the &quot; entity reference.
      [color=blue]
      > <img src="a.jpg" onClick="this.s rc=b.jpg;">[/color]

      But that wouldn't work, would it. It would be interpreted as: "assign the
      value of property jpg of object b, to property src of the current object
      (represented by this)". You would have to quote the string.

      [snip]
      [color=blue][color=green]
      >> Please note that I really cannot do the alternating
      >> single-quote-double-quote thing is[as?] the onClick action is set
      >> programatically and it is hard to detect exactly what's inside.[/color]
      >
      > That does not seem a valid statement, [...][/color]

      I agree.

      Mike

      --
      Michael Winter
      Replace ".invalid" with ".uk" to reply by e-mail.

      Comment

      • Evertjan.

        #4
        Re: help with quotes, please...

        Michael Winter wrote on 27 okt 2004 in comp.lang.javas cript:
        [color=blue][color=green]
        >> <img src="a.jpg" onClick="this.s rc=b.jpg;">[/color]
        >
        > But that wouldn't work, would it. It would be interpreted as: "assign
        > the value of property jpg of object b, to property src of the current
        > object (represented by this)". You would have to quote the string.
        >[/color]

        Yyyyyyyyyyyyyyy es.

        --
        Evertjan.
        The Netherlands.
        (Please change the x'es to dots in my emailaddress,
        but let us keep the discussions in the newsgroup)

        Comment

        Working...