Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    Regular Coder
    Join Date
    Apr 2003
    Location
    Northern California
    Posts
    169
    Thanks
    0
    Thanked 0 Times in 0 Posts

    document.images[i]

    Hello there agian! document.images[i] returns an array of all the images in the document right! Well this this leads to my questions! Does it return all the images in the document including thoughs in frames! Because I cant figure out how to reference frame then ask for images array!!

  • #2
    Regular Coder
    Join Date
    Aug 2002
    Location
    Silicon Valley, CA
    Posts
    980
    Thanks
    0
    Thanked 0 Times in 0 Posts
    parent.document.frames["frameName"].document.images;

  • #3
    Senior Coder
    Join Date
    Aug 2002
    Location
    UK
    Posts
    2,789
    Thanks
    2
    Thanked 14 Times in 14 Posts
    document.images.length will return the number of images in the document.

    This does not include images in other documents loaded into another frame

    In order to target another frame you use

    parent.main.document.images.length

    where main is the name of the frame

    So to reference the second image in another frame so would go


    parent.main.document.images[1]

  • #4
    Regular Coder
    Join Date
    Apr 2003
    Location
    Northern California
    Posts
    169
    Thanks
    0
    Thanked 0 Times in 0 Posts
    for some reason that doesn't work it returns a value of 0 but there are 24 images in that frame? And when I call specific image in the array it returns undefined? Could it be because I am using an iframe or am I just scripting challenged!

  • #5
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,075
    Thanks
    0
    Thanked 256 Times in 252 Posts
    try referencing the frame from the top. I usually do it this way.

    top.frames['nameOfTargetFrame'].document.images[i]
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #6
    Senior Coder
    Join Date
    Apr 2003
    Location
    Canada
    Posts
    1,063
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Maybe that frame uses frames....
    Shawn

  • #7
    Senior Coder
    Join Date
    Aug 2002
    Location
    UK
    Posts
    2,789
    Thanks
    2
    Thanked 14 Times in 14 Posts
    Here are three senarios




    In the page

    document.images.length


    In the page containing an Iframe

    setTimeout("alert(document.IframeName.document.images.length)",4000)

    From another frame in a frameset where a frame contains an Iframe

    setTimeout("alert(parent.FrameName.document.IframeName.document.images.length)",4000)


    The timeouts are to allow the page containing the images to load


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •