Javascript language

adplus-dvertising
Creating a Animated frame
Previous Home Next

How to Creating a Animated frame

Step 1. Written below code in your application.

<html>
<body onload="changeOneFrame()">
<script language="javascript">
var newWin = window.open('', 'f', 'width=400,height=400');
newWin.document.write('<frameset rows="50%,50%" cols="50%,50%">');
newWin.document.write('<frame name="f1" src="about:blank">');
newWin.document.write('<frame name="f2" src="about:blank">');
newWin.document.write('<frame name="f3" src="about:blank">');
newWin.document.write('<frame name="f4" src="about:blank">');
newWin.document.write('</frameset>');
colors = new Array("red","green","blue","yellow","white");
windows = new Array(newWin.f1, newWin.f2, newWin.f4, newWin.f3);
var c = 0, f = 0;
var timeout = null;
function changeOneFrame()
{
    windows[f].document.write('<BODY BGCOLOR="' + colors[c] + '">');
    windows[f].document.close();
    f = (f + 1) % 4;
    c = (c + 1) % 5;
    timeout = setTimeout("changeOneFrame()", 250);
}
</script>
<input type="button" value="Stop" 
onclick="if (timeout) clearTimeout(timeout); if (!n.closed) n.close();" />
</body>
</html>

Step 2. Run the Application.

Previous Home Next