javascript - change image of child window from parent window

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • newsteve1
    New Member
    • Aug 2007
    • 12

    #1

    javascript - change image of child window from parent window

    hello,

    i have a parent page with a bunch of photos. clicking on the first photo will lead to a new child window with a close-up of that photo AND from there you can cycle through all of the other photos from the previous page. Ive got the parent page and the child window page and the photo viewer working fine. What I want to do is to be able to do is have the same photo viewer window open up and display the particular photo that was originally clicked on (right now it always shows the first photo). I figure I should be able to talk to the child window through an 'onclick' and tell the child window to display 'so and so' image first, but I don't know how to communicate to the child window in this fashion...

    in short, how can i change the image of a child window from the parent window?

    thanks!
  • Atli
    Recognized Expert Expert
    • Nov 2006
    • 5062

    #2
    You could try adding a "anchor" to the URL, passing the ID (or whatever) of the image you want displayed.

    So, try opening a window with the URL formated like so:
    Code:
    http://example.com/childWindow.html#5
    Where 5 is the index of the photo you want viewed.

    Then you can use "document.locat ion.hash" to read the index and display the appropriate image.

    Comment

    Working...