@TageNov 12.2004 — #I think you can call functions from another frame, but I don't think you can affect another frame with functions from a different frame. To call the function try something like...(and I'm not sure about this, but it's a start)parent.frameName.functionName();Tage
@Stonehenge81authorNov 12.2004 — #Well I tried that command [parent.top.isWorking();] where top is the frame name and isWorking() is just a function that returns a alert window with some value.
Now the problem I got was two cases:
If I loaded the javascript call <SCRIPT SRC="script.js"> within that frame I'm calling from, I seems to just be calling that script itself, not the other script that is running on top.
If I remove the script within the, I get a error that I guess pretty much says the method doesn't exist.
Any other suggestion, please let me know, thanks much
@Stonehenge81authorNov 12.2004 — #It seems when I try the same thing it works.. But, I can't get current values that are in the other from when I make the call. DO you know what I might be doing wrong, if anything? Or is that just the nature of the function call?
@TageNov 12.2004 — #Are you trying to get a variable's information from another frame and use it in a different one? [color=silver]That may not be possible with javascript. It may be viewed as a security issue and is not allowed. =| I could be wrong though.[/color]
Tage
Edit: Actually I just tried it and it worked, why don't you post your code down? or send me a zip file
Edit 2: I've got to log, I'll check your post later, hopefully someone can help you out in the meantime though
Here is what i'm doing with your code Tage.... ---------------------
index.html:
<html>
<frameset rows="50%, 50%">
<frame src="frame1.html" name="frame1">
<frame src="frame2.html" name="frame2">
</frameset>
</html> ------------------
frame2:
<html>
<head>
<script type="text/javascript">
<!--
counter=0;
function runCounter()
{
for (i=0; i<100; i++)
counter++;
alert(counter);
}
function getCounter()
{
alert(counter);
}
//-->
</script>
<body onLoad="runCounter()">
frame2
</body>
</html> -------------------
frame1:
<html>
<SCRIPT LANGUAGE="javascript">
function run()
{
parent.frame2.getCounter();
}
</SCRIPT>
<body onLoad="run()">
frame1
</body>
</html> --------------------
So basically... Frame 1 runs itself once, giving counter 100 and sending an alert of it.
THEN Frame 2 calls a function in Frame 1 to get the status of counter, which SHOULD be 100, but instead is 0 and gives an alert of it
I think you might be right, but if you or anyone else has any other suggestions, please let me know, thanks much!
The only reason I'm going through all this is to make my life a lot easier and keep from having do to a lot of repetative code, which has been the downside of using frames, but that again is easier for me to implament'ish.
@Stonehenge81authorNov 12.2004 — #Well I fixed my last reply sorry. Tend to do that sometimes. Anywho, actually Tages codes works and it does work on another frames active script, but right now I have problems with my own script. Once I am done documenting my script I'll see if I can upload it here so someone can try to help me with what I'm trying to do
@Stonehenge81authorNov 12.2004 — #MY gosh it works!!! WOo hoo!!! THanks a lot Tage...
What happened in my code was that I'm guessing that I was using a reserved word for my frame NAME="top". I changed it to topFrame and it works just find and it calls all whatever active script in another page just fine as well!! I'll still load my script and what exactly I'm doning once I finish with it. Thanks again!