Javascript question

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

    Javascript question

    Hello,

    I am trying to create a slideshow with Javascript and found the script
    below, which is very nice. The only thing I want is to add a
    description to every image that appears in the slideshow, the script
    below only show the full sized image.
    Does anybody have an idea if that is possible using this script, or
    does anybody have another script which lets me do that ?
    Thanks a bunch in advance for your help !

    <SCRIPT LANGUAGE="JavaS cript" TYPE="text/javascript">
    <!--

    // canManipulateIm ages - check if the browser we're using can do
    // clever stuff with document images.

    function canManipulateIm ages() {
    if (document.image s)
    return true;
    else
    return false;
    }

    // loadPosterImage

    function loadPosterImage (imageURL) {
    if (gImageCapableB rowser) {
    document.imageP oster.src = imageURL;
    return false;
    }
    else {
    return true;
    }
    }

    // gImageCapableBr owser - is this browser hip to images? Set up
    // a global variable so that we don't have to keep calling a function
    // (useful if the function becomes costly to compute).

    gImageCapableBr owser = canManipulateIm ages();

    // -->
    </SCRIPT>

    <TABLE CELLPADDING=10 CELLSPACING=5 WIDTH="95%" ALIGN=CENTER>
    <TR>
    <TD VALIGN=TOP ALIGN=CENTER>
    <A HREF="inline/imageNaiad.jpg"
    onClick="return (loadPosterImag e('inline/imageNaiad.jpg' ))">
    <IMG SRC="inline/imageNaiadSmall .jpg"
    ALT="Naiad" BORDER=0 ALIGN=TOP WIDTH=56 HEIGHT=75></A>
    <P CLASS="thumbcap tion">Naiad Beauty Products</P>
    </TD>
    <TD VALIGN=TOP ALIGN=CENTER>
    <A HREF="inline/imageAdonis.jpg "
    onClick="return (loadPosterImag e('inline/imageAdonis.jpg '))">
    <IMG SRC="inline/imageAdonisSmal l.jpg"
    ALT="Adonis" BORDER=0 ALIGN=TOP WIDTH=56 HEIGHT=75></A>
    <P CLASS="thumbcap tion">Bronze Adonis</P>
    </TD>
    <TD WIDTH=250 VALIGN=TOP ALIGN=CENTER ROWSPAN=3>
    <IMG SRC="inline/imageNaiad.jpg" NAME="imagePost er"
    ALT="Naiad" ALIGN=TOP WIDTH=225 HEIGHT=300>
    </TD>
    </TR>
    <TR>
    <TD VALIGN=TOP ALIGN=CENTER>
    <A HREF="inline/imageRodin.jpg"
    onClick="return (loadPosterImag e('inline/imageRodin.jpg' ))">
    <IMG SRC="inline/imageRodinSmall .jpg"
    ALT="Rodin" BORDER=0 ALIGN=TOP WIDTH=56 HEIGHT=75></A>
    <P CLASS="thumbcap tion">Rodin Consulting</P>
    </TD>
    <TD VALIGN=TOP ALIGN=CENTER>
    <A HREF="inline/imageSwami.jpg"
    onClick="return (loadPosterImag e('inline/imageSwami.jpg' ))">
    <IMG SRC="inline/imageSwamiSmall .jpg"
    ALT="Swami" BORDER=0 ALIGN=TOP WIDTH=56 HEIGHT=75></A>
    <P CLASS="thumbcap tion">Swami Academy</P>
    </TD>
    </TR>
    <TR>
    <TD VALIGN=TOP ALIGN=CENTER>
    <A HREF="inline/imagePassion.jp g"
    onClick="return (loadPosterImag e('inline/imagePassion.jp g'))">
    <IMG SRC="inline/imagePassionSma ll.jpg"
    ALT="Passion" BORDER=0 ALIGN=TOP WIDTH=56 HEIGHT=75></A>
    <P CLASS="thumbcap tion">Plastic Passion</P>
    </TD>
    <TD VALIGN=TOP ALIGN=CENTER>
    <A HREF="inline/imageAtlas.jpg"
    onClick="return (loadPosterImag e('inline/imageAtlas.jpg' ))">
    <IMG SRC="inline/imageAtlasSmall .jpg"
    ALT="Atlas" BORDER=0 ALIGN=TOP WIDTH=56 HEIGHT=75></A>
    <P CLASS="thumbcap tion">Atlas Removals</P>
    </TD>
    </TR>
    </TABLE>

    Regards,

    GP

  • Dr John Stockton

    #2
    Re: Javascript question

    JRS: In article <1119041350.080 514.95800@g47g2 000cwa.googlegr oups.com>,
    dated Fri, 17 Jun 2005 13:49:10, seen in news:comp.lang. javascript,
    nazgulero <georg.pauwen@w anadoo.nl> posted :[color=blue]
    >
    >function canManipulateIm ages() {
    > if (document.image s)
    > return true;
    > else
    > return false;
    >}[/color]

    That, unless you are paid by the yard, can be written more like


    function canManipulateIm ages() {
    return !!document.imag es
    }

    or

    function canManipulateIm ages() { !!return document.images }

    --
    © John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 IE 4 ©
    <URL:http://www.jibbering.c om/faq/> JL/RC: FAQ of news:comp.lang. javascript
    <URL:http://www.merlyn.demo n.co.uk/js-index.htm> jscr maths, dates, sources.
    <URL:http://www.merlyn.demo n.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.

    Comment

    • Yann-Erwan Perio

      #3
      Re: Javascript question

      Dr John Stockton wrote:

      Hi John,
      [color=blue]
      > function canManipulateIm ages() { !!return document.images }[/color]

      Et là, c'est le drame.

      In current javascript, the "logical not" operator "!" is applied to a
      following unary expression - not a statement.

      Favorite hot beverage break ? ;-)


      Cheers,
      Yep.

      Comment

      • RobG

        #4
        Re: Javascript question

        Dr John Stockton wrote:
        [...][color=blue]
        >
        > That, unless you are paid by the yard, can be written more like
        >[/color]

        Indeed. The function is used to assign a value to the global
        variable gImageCapableBr owser, which itself contains 5 more
        characters that the equivalent (and more direct):

        if ( document.images ) {
        ...
        }

        :-)

        --
        Rob

        Comment

        • Dr John Stockton

          #5
          Re: Javascript question

          JRS: In article <42b4aedb$0$992 1$626a14ce@news .free.fr>, dated Sun, 19
          Jun 2005 01:31:41, seen in news:comp.lang. javascript, Yann-Erwan Perio
          <yep@invalid.co m> posted :[color=blue]
          >Dr John Stockton wrote:
          >
          >Hi John,
          >[color=green]
          >> function canManipulateIm ages() { !!return document.images }[/color]
          >
          >Et là, c'est le drame.
          >
          >In current javascript, the "logical not" operator "!" is applied to a
          >following unary expression - not a statement.
          >
          >Favorite hot beverage break ? ;-)[/color]

          Indeed; but the typo was evident from what you did not quote.

          What's a unary expression as opposed to any other sort of expression?

          --
          © John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 IE 4 ©
          <URL:http://www.jibbering.c om/faq/> JL/RC: FAQ of news:comp.lang. javascript
          <URL:http://www.merlyn.demo n.co.uk/js-index.htm> jscr maths, dates, sources.
          <URL:http://www.merlyn.demo n.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.

          Comment

          • Yann-Erwan Perio

            #6
            Re: Javascript question

            Dr John Stockton wrote:

            <snip>
            [color=blue]
            > What's a unary expression as opposed to any other sort of expression?[/color]

            The ECMAScript specification defines several types of expressions, in
            order to precisely describe the language grammar; among these
            expressions, listed in ECMA262-3 A3, has been defined UnaryExpression ,
            which is basically[1] an expression following a unary operator
            (ECMA262-3, 11.4).

            UnaryExpression :
            PostfixExpressi on
            delete UnaryExpression
            void UnaryExpression
            typeof UnaryExpression
            ++ UnaryExpression
            -- UnaryExpression
            + UnaryExpression
            - UnaryExpression
            ~ UnaryExpression
            ! UnaryExpression


            Cheers,
            Yep.

            ---
            [1] The PostfixExpressi on is listed as a UnaryExpression , and can
            concern different types of other expressions.

            Comment

            Working...