CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7

Threaded View

  1. #1
    Join Date
    Mar 2006
    Posts
    228

    How to load image from another page

    hello,

    I am using JavaScript to do the following:

    I have 2 pages that I am using..

    Page 1 has all the images on it (images.htm)
    Page 2 is the page I want to display the images. (main.htm)

    So what I am tring to do is, on Page 1 it has a image on there using the img tag it also has a ID tag.

    I want to use Page 2 get that image source from page 1 by the img tag using the ID tag.

    however there is more than 1 image on Page 1. but once I work out how to do one I will know how to do the rest.

    I know this sounds silly to load the page this way, but Page 1 no one will see and I want to be able to get the image source from that page.

    anyone have any ideas on how to do this? Hope you understand what I am tring to do.

    So far I know how to get the image source if it's on the same page but don't know how to get the image source from another local page..

    Code:
    var a=document.getElementsByTagName('a');
    for(var i=0; i<a.length; i++)
    {
        var img=a[i].getElementsByTagName('img');
        for(var j=0; j<img.length; j++)
        {
            alert(img[j].src);
        }
    }
    Thanks.
    Last edited by aaronking; January 13th, 2012 at 08:47 PM.

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured