Monday 1 April 2013

Marque Example in JavaScript


<html>
<head>
<!--
<script>
    function startLoop() {
    setInterval( "doSomething()", 5000 ); }
    function doSomething() {
    document.getElementById('myMarquee').stop(); }
</script>
-->
<script>
var step = 1; // marquee is run on load time
function startLoop()
{
    setInterval("doSomething()", 4000 );
}
function doSomething()
{
    if (step == 0) {
        // 5 seconds are passed since marquee stopped
        document.getElementById('myMarquee').start();
        step = 1;
    }
    else
    {
        if (step == 1) {
            // 5 seconds are passed since marquee started
            step = 2; // Just delay of another 5 seconds before stop
        }
        else
        {
            if (step == 2) {
                // 10  seconds are passed since marquee started
                document.getElementById('myMarquee').stop();
                step = 0;
            }
        }
    }              
}
</script>


</head>
<body onload="startLoop();">
<table width=30% border=2>
  <tr>
    <td width=100% align=center
      valign=center>
      <marquee align="middle"
         behavior="scroll" 
 id="myMarquee"
        bgcolor="Black"
        direction="up"
align="center"
        height="200"
        width="100%"
onmouseover="this.stop();"
onmouseout="this.start();"
        scrollamount="1"
        scrolldelay="50">
        <font color="#30ec0f" 
        size=2><b>
        Text 1
        </b></font>
<font color="#de082d" 
        size=2><b><br><br><br>
Text2
</b></font>
<b><br><br><br>
 <font color="#30ec0f" 
        size=2><b>
       Text 3
        </b></font>
<font color="#de082d" 
        size=2><b><br><br><br>
      </marquee>
    </td>
  </tr>
</table>

</body>
</html>

No comments:

Post a Comment