Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

animated expanding frame

Posted on 2004-03-31
7
Medium Priority
?
768 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
  • 4
  • 3
7 Comments
 
LVL 9

Accepted Solution

by:
lombardp earned 500 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

885 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