Refrencing Images

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • HTML-JSClub

    Refrencing Images

    Anyone know how to refrence images? like GetElementByID except for
    images. I alread tried ...ByID ...ByName ...ByValue GetImageBy[previous
    ones].

  • Random

    #2
    Re: Refrencing Images

    <img ... id=foo name=foo />

    document.images[0] === document.images[ 'foo' ] ===
    document.getEle mentById( 'foo' );

    Comment

    • Michael Winter

      #3
      Re: Refrencing Images

      On 22/05/2005 06:50, Random wrote:
      [color=blue]
      > <img ... id=foo name=foo />
      >
      > document.images[0] === document.images[ 'foo' ][/color]

      Assuming 'foo' is the first image in the document, otherwise the index
      (0) will be different.
      [color=blue]
      > === document.getEle mentById( 'foo' );[/color]

      Even when an id attribute value is present on an image in a HTML
      document, it is preferable to use the images collection above. It is
      supported on more user agents and is self-documenting.

      Mike

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

      Comment

      • Random

        #4
        Re: Refrencing Images

        hands[ 1 ].add( new Thumb( { direction: 1 } ) );

        or, rather,

        hands[ 'right' ].add( new Thumb( { direction: 'up' } ) );

        Comment

        • HTML-JSClub

          #5
          Re: Refrencing Images

          Ok thx, i'll try them as soon as i can

          Comment

          • HTML-JSClub

            #6
            Re: Refrencing Images

            i'm wondering, can i put in stead of a # in /document.images[0]/, can i
            put a variable /document.images[myimg]/?

            Comment

            • HTML-JSClub

              #7
              Re: Refrencing Images

              never mind that, new problem: why isn't this working?
              [color=blue]
              > document.images[imgfile] === document.images[currX] ===[/color]
              document.getEle mentById(currX) .src="man.jpg";

              Comment

              • HTML-JSClub

                #8
                Re: Refrencing Images

                LOL, i keep solving my own problems (needed 3 ===) thx for all your
                help Micheal , "Random"

                Comment

                • Randy Webb

                  #9
                  Re: Refrencing Images

                  HTML-JSClub wrote:
                  [color=blue]
                  > LOL, i keep solving my own problems (needed 3 ===) thx for all your
                  > help Micheal , "Random"
                  >[/color]

                  Now all we have to do is manage to teach you how to quote and reply
                  properly.

                  --
                  Randy
                  comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
                  Answer:It destroys the order of the conversation
                  Question: Why?
                  Answer: Top-Posting.
                  Question: Whats the most annoying thing on Usenet?

                  Comment

                  • HTML-JSClub

                    #10
                    Re: Refrencing Images

                    sry i had asked a question but when i solved it i deleted it off the
                    thread, i thought i had deleted the one you just quoted too.
                    the question was " Why isnt this working? document.images[0] ===
                    document.images[ 'foo' ] ===
                    document.getEle mentById( 'foo' ). src = 'image.jpg' "
                    The answer was that i needed 3 === after .src
                    sry for the confusion

                    Comment

                    • Michael Winter

                      #11
                      Re: Refrencing Images

                      On 24/05/2005 06:02, HTML-JSClub wrote:
                      [color=blue]
                      > never mind that, new problem: why isn't this working?
                      >[color=green]
                      >> document.images[imgfile] === document.images[currX] ===
                      >> document.getEle mentById(currX) .src="man.jpg";[/color][/color]

                      All you want is:

                      document.images[currX].src = 'man.jpg';

                      In an earlier post where Random wrote:
                      [color=blue]
                      > <img ... id=foo name=foo />
                      >
                      > document.images[0] === document.images[ 'foo' ] ===
                      > document.getEle mentById( 'foo' );[/color]

                      the point was that you could use

                      document.images['foo'] or,
                      document.getEle mentById('foo')

                      to refer to it. If that image was the n'th image in the document, you
                      could also use

                      document.images[ <n> ]

                      instead. The intent wasn't for you to use all of them.

                      Mike

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

                      Comment

                      • Randy Webb

                        #12
                        Re: Refrencing Images

                        HTML-JSClub wrote:
                        [color=blue]
                        > sry i had asked a question but when i solved it i deleted it off the
                        > thread, i thought i had deleted the one you just quoted too.
                        > the question was " Why isnt this working? document.images[0] ===
                        > document.images[ 'foo' ] ===
                        > document.getEle mentById( 'foo' ). src = 'image.jpg' "
                        > The answer was that i needed 3 === after .src
                        > sry for the confusion
                        >[/color]

                        And you still missed the most important part of what I posted.

                        <quote>

                        Now all we have to do is manage to teach you how to quote and reply
                        properly.

                        </quote>

                        --
                        Randy
                        comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
                        Answer:It destroys the order of the conversation
                        Question: Why?
                        Answer: Top-Posting.
                        Question: Whats the most annoying thing on Usenet?

                        Comment

                        • HTML-JSClub

                          #13
                          Re: Refrencing Images

                          OK I'M SORRY!!!! and I finally get it thanks to Micheal and if i'm
                          still missing the point than i have NOOOOOO idea what you're talking
                          about.

                          Comment

                          • Richard Cornford

                            #14
                            Re: Refrencing Images

                            HTML-JSClub wrote:[color=blue]
                            > Randy Webb wrote:[color=green]
                            >>HTML-JSClub wrote:[color=darkred]
                            >>> Randy Webb wrote:[/color][/color][/color]
                            <snip>[color=blue][color=green][color=darkred]
                            >>>> Now all we have to do is manage to teach you
                            >>>> how to quote and reply properly.[/color][/color][/color]
                            <snip>[color=blue][color=green][color=darkred]
                            >>>sry for the confusion[/color][/color][/color]
                            <snip>[color=blue][color=green]
                            >>And you still missed the most important part of what I posted.[/color][/color]
                            <snip>[color=blue]
                            > ... if i'm still missing the point than i have
                            > NOOOOOO idea what you're talking about.[/color]

                            Concentrate on the words "how to quote".

                            Richard.


                            Comment

                            • HTML-JSClub

                              #15
                              Re: Refrencing Images

                              o....k..... i dont remember quoting anything. And now I have a
                              question: in switch statements can i have it like:[color=blue]
                              >case str1:[/color]
                              or does it have to be a string or number?

                              Comment

                              Working...