PDA

View Full Version : passing variables from frame to frame


just_a_gurl
01-30-2005, 08:19 PM
Having biiiiiggg issues trying to figure out how to pass variables from one frame to another. What I am trying to do is in one frame have a thumbnail of backgrounds, and when you click on the thumbnail it puts the background as the full background into the other frame.... PLEASE HELPPPPPPPPP MEEEEEEE!! ~Ashley

_Aerospace_Eng_
01-30-2005, 09:37 PM
okay u can try something like this i dont know if it will work in a frameset(you can try) but it should work with iframes
add this in between the head tags of the page that has the images
<script type="text/javascript">
function changebg(bgimage){
parent.left.document.body.background=''+bgimage+''
}
</script>
that function has a variable called bgimage so u can use the same function over again just changing the image location in the link
<a href="javascript:;" onclick="changebg('yourbgimage.gif')">link</a>
okay how it would work is lets say u had a page with two iframes and u had the images in the right iframe and u wanted to change the background of the left iframe so if u give the left iframe and id of "left" once u click the link it will change the background image of that iframe if u want to call the frames a different name then go ahead just change the word left that is in the function that comes after the word parent to the id of the frame u want to change
p.s. take the space out of the word javascript

just_a_gurl
02-01-2005, 04:16 PM
Thank you so much, I used it with iframes and got it to work wonderfully!! ~Ashley