Solved

animated expanding frame

Posted on 2004-03-31
7
762 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 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

929 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now