onError problem loading an image

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jürgen Heyn

    #1

    onError problem loading an image

    Good afternoon,

    I am handing a string as a parameter pImage = "Images/Available.jpg"
    If this image is NOT available I would like to load Images/NoImage.jpg.
    Unfortunately the following code does NOT work.
    obj.write('<p>< img src=' + pImage + '
    onError="self.s rc="Images/NoImage.jpg"" border="0"></p>');
    Where is my mistake ?
    I appreciate any hint.
    Best regards
    Juergen Heyn, Wilhelmshaven, Germany


  • Ivo

    #2
    Re: onError problem loading an image

    "Jürgen Heyn" <j.heyn@gmx.d e> wrote in message
    news:c1sm8q$1n2 clk$1@ID-94872.news.uni-berlin.de...[color=blue]
    > Good afternoon,
    >
    > I am handing a string as a parameter pImage = "Images/Available.jpg"
    > If this image is NOT available I would like to load Images/NoImage.jpg.
    > Unfortunately the following code does NOT work.
    > obj.write('<p>< img src=' + pImage + '
    > onError="self.s rc="Images/NoImage.jpg"" border="0"></p>');[/color]

    Try onError="this.s rc
    ^^^^^


    Comment

    • Ivo

      #3
      Re: onError problem loading an image

      "Ivo" <no@thank.you > wrote[color=blue]
      > "Jürgen Heyn" <j.heyn@gmx.d e> wrote[color=green]
      > > I am handing a string as a parameter pImage = "Images/Available.jpg"
      > > If this image is NOT available I would like to load Images/NoImage.jpg.
      > > Unfortunately the following code does NOT work.
      > > obj.write('<p>< img src=' + pImage + '
      > > onError="self.s rc="Images/NoImage.jpg"" border="0"></p>');[/color]
      >
      > Try onError="this.s rc
      > ^^^^^[/color]
      That was too quick. You also have a double-quoted string inside a
      double-quoted string, which the interpreter won't understand if you don't
      escape the innerquotes:
      onError="this.s rc=\"Images/NoImage.jpg\";"
      or
      onError="this.s rc='Images/NoImage.jpg';"

      untested,
      Ivo




      Comment

      • Richard Cornford

        #4
        Re: onError problem loading an image

        Ivo wrote: <4041e874$0$632 87$cd19a363@new s.wanadoo.nl>[color=blue]
        > "Ivo" <no@thank.you > wrote[color=green]
        >> "Jürgen Heyn" <j.heyn@gmx.d e> wrote[/color][/color]
        <snip>[color=blue][color=green][color=darkred]
        >>> NOT work. obj.write('<p>< img src=' + pImage + '
        >>> onError="self.s rc="Images/NoImage.jpg"" border="0"></p>');[/color]
        >>
        >> Try onError="this.s rc
        >> ^^^^^[/color]
        > That was too quick. You also have a double-quoted string inside a
        > double-quoted string, which the interpreter won't understand if you
        > don't escape the innerquotes:
        > onError="this.s rc=\"Images/NoImage.jpg\";"
        > or
        > onError="this.s rc='Images/NoImage.jpg';"[/color]

        Take another step back any you will observe that the double quoted
        string inside the double quoted string is itself inside a single quoted
        string of HTML. Escaping the quotes within the onerror handler will work
        for the javascript interpreter but will not be enough for the HTML
        parser if the inner set of quotes remain double.

        obj.write('<p>< img src="'+pImage +
        '" onError="this.s rc=\'Images/NoImage.jpg\';" border="0"></p>');

        Richard.


        Comment

        • Jürgen Heyn

          #5
          Re: onError problem THANK YOU

          Gentlemen,
          thank you very much for your response.
          Richard's suggestion works perfectly.
          Have a nice rest of this sunday.
          Best regards
          Juergen Heyn, Wilhelmshaven, Germany


          Comment

          Working...