Wrox Home  
Search P2P Archive for: Go

  Return to Index  

javascript thread: Calling a function from a different frame


Message #1 by "Ahmed Barradah" <havana200@h...> on Sun, 29 Jul 2001 06:04:08
parent.<frame name>.<function name> will work as long as the frames are 
from the same server.

At 06:04 29/07/01 +0000, you wrote:


>Hi,
>   I have a function in the Upperframe that I want to call it from the main
>frame window of my web site using the onSubmit event. Here is the
>JavaScript code for my Upperframe
>
><SCRIPT LANGUAGE = JavaScript>
><!--
>
>var timeLeft = -1;
>var quizTimerId = 0;
>
>function Start()
>{
>
>    var timeLimit = 5;
>    window.reset(timeLimit);
>
>}
>function reset(timeLimit)
>{
>    timeLeft = timeLimit;
>
>   if (timeLeft == -1)
>    {
>       alert("No Time Limit");
>    }
>    else
>    {
>       TimerId = window.setInterval("updateTimeLeft()",6000);
>    }
>}
>
>function updateTimeLeft()
>{
>   timeLeft--;
>
>   if (timeLeft == 0)
>   {
>     alert("Time's Up");
>     window.parent.location ="End.asp";
>   }
>   else
>   {
>     var minutes = Math.floor(timeLeft / 60);
>     var seconds = timeLeft - (60 * minutes);
>
>     if (minutes < 10)
>        minutes = "0" + minutes;
>
>     if (seconds <10)
>         seconds = "0" + seconds;
>     alert("Time Left is " + minutes + ":" + seconds);
>   }
>
>}
>//-->
></script>
>
>and I am calling it from the main frame using this code:
>
><FORM ACTION="CheckLogin1.asp <% If Request("Again") = "1" then %>?
>Again=1<% End If %>"  METHOD="POST" onSubmit= "window.Upperframe.start()">
>
>However, I'm getting an error message everytime. I have four frames and I
>want the form in the main frame to call the Start function in the
>Upperframe. Can anyone tell me what I'm doing wrong!!!
>
>  Thank you,
>  Ahmed
>
>

  Return to Index