Solved

animated expanding frame

Posted on 2004-03-31
7
765 Views
Last Modified: 2013-11-19
I am trying to create an animated expanding frame and I think I'm close but it's definetly not right. I'm using the "setTimeout" function to call the frame expansion functions but, either my time setting is off or I'm just not doing it right. I certainly don't understand the concept behind sequential function calls. Could you help and explain?

frames page:
------------------------------------------------------------------------------------

<frameset rows="80,300,*" framespacing="0" frameborder="0" id="ro">
    <frame name="head" src="blank.html" marginwidth="0" marginheight="0" scrolling="no" frameborder="0" noresize>
    <frameset  cols="*,400,*" framespacing="0" frameborder="0" id="exp">
        <frame name="left" src="blank.html" marginwidth="0" marginheight="0" scrolling="no" frameborder="0" noresize>
        <frame name="content" src="for.html" marginwidth="0" marginheight="0" scrolling="no" frameborder="0" noresize>
        <frame name="right" src="blank.html" marginwidth="0" marginheight="0" scrolling="no" frameborder="0" noresize>
    </frameset>
    <frame name="bot" src="blank.html" marginwidth="0" marginheight="0" scrolling="no" frameborder="0" noresize>
</frameset>



javascript:
------------------------------------------------------------------------------------

<script language="JavaScript">

function exp0(){
// the first one is if you want to remove the side frame...
parent.document.all("ro").all("exp").cols="*,450,*";
}
function exp1(){
// the first one is if you want to remove the side frame...
parent.document.all("ro").all("exp").cols="*,500,*";
}
function exp2(){
// the first one is if you want to remove the side frame...
parent.document.all("ro").all("exp").cols="*,550,*";
}
function exp3(){
// the first one is if you want to remove the side frame...
parent.document.all("ro").all("exp").cols="*,600,*";
}

var a = window.setTimeout('exp0()', 100000);
var b = window.setTimeout('window.clearTimeout(a)', 0);
var c = window.setTimeout('exp1()', 100000);
var d = window.setTimeout('window.clearTimeout(c)', 0);
var e = window.setTimeout('exp2()', 100000);
var f = window.setTimeout('window.clearTimeout(e)', 0);
var g = window.setTimeout('exp3()', 100000);
</script>

thanks
0
Comment
Question by:dsyn
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 9

Accepted Solution

by:
lombardp earned 125 total points
ID: 10724237
I'm not sure to understand the effect, but if you want to implement a sequence of function calls (exp0 then after 10000ms exp1, then after 10000ms exp2,... and so on), the script should be like this:

<script language="JavaScript">

function exp0(){
parent.document.all("ro").all("exp").cols="*,450,*";   // CHANGE PARAMETERS
window.setTimeout('exp1()', 100000);                     // START TIMER FOR EXP1 CALL
}

function exp1(){
parent.document.all("ro").all("exp").cols="*,500,*";  // CHANGE PARAMETERS
window.setTimeout('exp2()', 100000);                     // START TIMER FOR EXP2 CALL
}

function exp2(){
parent.document.all("ro").all("exp").cols="*,550,*";   // CHANGE PARAMETERS
window.setTimeout('exp3()', 100000);                     // START TIMER FOR EXP3 CALL
}

function exp3(){
parent.document.all("ro").all("exp").cols="*,600,*";
}

window.setTimeout('exp0()', 100000);

</script>

SETTIMEOUT is a sort of delayed execution of the given function, with the delay set by the user.
0
 
LVL 1

Author Comment

by:dsyn
ID: 10727297
It worked! I reduced the time from "100000" to "1" and the frame expanded with a real animated look. It looks really cool. Thanks!

Now the thing I did wrong was that I had to many "timeouts"?  
0
 
LVL 9

Expert Comment

by:lombardp
ID: 10729865
Since SETTIMEOUT is a sort of delayed execution of the given function, with the delay set by the user, you have to start timer for function EXP1 just __AFTER__ the timeout for EXP0 has expired.

This is the correct sequence:

1) start timeout for EXP0
2) after X ms EXP0 is executed
3) start timeout for EXP1
4) after X ms EXP1 is executed
5) start timeout for EXP2
...

If you write:

var a = window.setTimeout('exp0()', 100000);
var c = window.setTimeout('exp1()', 100000);
var e = window.setTimeout('exp2()', 100000);
var g = window.setTimeout('exp3()', 100000);

All timers start (and expire) togeteher.

And adding:

var b = window.setTimeout('window.clearTimeout(a)', 0);
var d = window.setTimeout('window.clearTimeout(c)', 0);
var f = window.setTimeout('window.clearTimeout(e)', 0);

Timers are canceled just after the start.

0
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 
LVL 1

Author Comment

by:dsyn
ID: 10731686
One more question. The script doesn't work in netscape. I never even thought to try it till my page was setup. :| is there a way to make it work?  Thanks for the explanation...
0
 
LVL 9

Expert Comment

by:lombardp
ID: 10731736
Do you mean Netscape 4.x or 7.x/Mozilla ?
0
 
LVL 1

Author Comment

by:dsyn
ID: 10731780
so far I tried it with netscape 4.8 and 7.02
0
 
LVL 9

Expert Comment

by:lombardp
ID: 10731894
The problem is the DOM, try this:

Netscape 7.x and MSIE
---------------------------

<script language="JavaScript">

function exp0(){
parent.document.getElementById("exp").cols="*,450,*";   // CHANGE PARAMETERS
window.setTimeout('exp1()', 100000);                     // START TIMER FOR EXP1 CALL
}

function exp1(){
parent.document.getElementById("exp").cols="*,500,*";  // CHANGE PARAMETERS
window.setTimeout('exp2()', 100000);                     // START TIMER FOR EXP2 CALL
}

function exp2(){
parent.document.getElementById("exp").cols="*,550,*";   // CHANGE PARAMETERS
window.setTimeout('exp3()', 100000);                     // START TIMER FOR EXP3 CALL
}

function exp3(){
parent.document.getElementById("exp").cols="*,600,*";
}

window.setTimeout('exp0()', 100000);

</script>

0

Featured Post

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question