why do both lines of code work?!

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Geoff Cox

    why do both lines of code work?!

    Hello,

    I have 2 lines of code which are different but both work. I refer to
    the 3rd line with the url in it. In the first case the // are not
    escaped, in the second they are.

    Either

    soundManager.cr eateSound({
    id:'mySound'+t,
    url:'http://www.site.com/files/Track' + (+t+35) + '.mp3',
    onfinish:functi on(){document.g etElementById(' test'+t+1).clas sName =
    'visibleDiv2'} });
    soundManager.pl ay('mySound'+t) ;
    count++;

    Or

    soundManager.cr eateSound({
    id:'mySound'+t,
    url:'http:\/\/www.site.com/files/Track' + (+t+35) + '.mp3',
    onfinish:functi on(){document.g etElementById(' test'+t+1).clas sName =
    'visibleDiv2'} });
    soundManager.pl ay('mySound'+t) ;
    count++;

    The only difference as far as I can see is that with the

    url:'http://www.site.com/files/Track' + (+t+35) + '.mp3',

    the part after http: to the end of the line is grayed out with
    Homesite (my html editor) whereas with

    url:'http:\/\/www.site.com/files/Track' + (+t+35) + '.mp3',

    it is not.

    Is there any other difference?! I am used to the idea of escaping
    various characters but usually the "\" is required for the code to
    work.

    Cheers

    Geoff
  • Gregor Kofler

    #2
    Re: why do both lines of code work?!

    Geoff Cox meinte:
    Is there any other difference?! I am used to the idea of escaping
    various characters but usually the "\" is required for the code to
    work.
    No. / don't need to be escaped. You can, however - as you noticed it
    won't have any effect, except worsening the readability. Masking is
    needed though, when working with regular expressions.

    Gregor


    --
    http://photo.gregorkofler.at ::: Landschafts- und Reisefotografie
    http://web.gregorkofler.com ::: meine JS-Spielwiese
    http://www.image2d.com ::: Bildagentur für den alpinen Raum

    Comment

    • Geoff Cox

      #3
      Re: why do both lines of code work?!

      On Wed, 07 May 2008 11:17:20 +0200, Gregor Kofler
      <usenet@gregork ofler.atwrote:
      >Geoff Cox meinte:
      >
      >Is there any other difference?! I am used to the idea of escaping
      >various characters but usually the "\" is required for the code to
      >work.
      >
      >No. / don't need to be escaped. You can, however - as you noticed it
      >won't have any effect, except worsening the readability. Masking is
      >needed though, when working with regular expressions.
      >
      >Gregor
      Thank Gregor - feel better now!

      Cheers

      Geoff

      Comment

      Working...