...

View Full Version : Calling functions in different frames



Thompson
08-07-2006, 11:39 PM
Hi, friends!

Take a look on the following problem:

I have two pages: functionPage.html and executionPage.html.

Here's the code of funcionPage.html:


<script>
function setImageSrc( path, obj )
{
obj.src = path;
}
</script>

<html>
<frameset>
<frame src="executionPage.html"></frame>
</frameset>
</html>



Now, here's the code of executionPage.html:


<script>
window.onLoad = parent.frames.setImageSrc( "/images/someImage.gif" document.getElementById("image") );
</script>
<html>
<body>
<img src="" id="image" />
</body>
</html>


As you guys can see, I have a main page that contains the funcion setImageSrc(), and inside this page I have a frame that loads the page executionPage.html.

Here's the problem: when I call the instruction parent.frames.setImageSrc(), I DO NOT want to reffer to an image positioned in the functionPage.html. I want that he reffers to the image stored in executionPage.html!!!
But calling funcions using parent.frames it seems that I cannot do this.

Is there another way that i could call a function with parent.frames, but reffering to elements of the page that is calling the function?

Or I have to make an include? I do not want to do it.... but I'm being forced to use it, i guess.

Anyone have an idea??

Thanks for the help, folks! :D

glenngv
08-08-2006, 03:32 PM
window.onload = function(){
if (parent.setImageSrc) {
parent.setImageSrc("/images/someImage.gif", document.getElementById("image"));
}
}

Thompson
08-09-2006, 10:37 PM
Thanks!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum