Display a dynamic Ticker tape by Max Cappellari

Contributed by
Rating: 4 stars4 stars4 stars4 stars4 stars / 3
February 18, 2002
Rate this Article:
MEH MEH++


SEARCH ASP FREE
TOOLS YOU CAN USE

advertisement

Display a dynamic Ticker tape. The content can be read from a database.
The speed, background color, font, width and height can be customized.
This project is divided into 2 parts:

1) Include File: Ticker Tape Code (TickerInclude.asp)
2) Main file: the file you want to put the Ticker tape into.


Here is the code:

TickerInclude.asp

<%
    'Created by Max Cappellari
    'to get the content from a Database:
    'simply create a Recordset object here.
   
   
    Link1 = "<a href='http://www.yahoo.com'>http://www.yahoo.com</a>"
    Link2 = "<a href='http://www.cnn.com'>http://www.cnn.com</a>"
    Link3 = "<a href='http://www.aol.com'>http://www.aol.com</a>"
   
    'Settings
    TickerColor = "#9CD3FF"
    TickerHeight = 15
    TickerWidth = 300
   
%>

<style>
<!--
#tickertape {
position:relative;
layer-background-color:<%=TickerColor%>;
width:<%=Tickerwidth%>;
height:<%=TickerHeight%>;
}

#subtickertape{
background-color:<%=TickerColor%>;
position:absolute;
border: 0px <%=TickerColor%>
width:<%=Tickerwidth%>;
height:<%=TickerHeight%>;
}

.subtickertapefont {
font: 12px underlined Verdana;
text-decoration:none;
color:black;
}

.subtickertapefont a {
color:black;
text-decoration:none;
}
-->
</style>

<script language="JavaScript">

function regenerate() {
    window.location.reload()

}

function regenerate2() {
    if (document.layers)
        setTimeout("window.onresize = regenerate",450)
}

function update() {
   
    if (document.layers){
        document.tickertape.document.subtickertape.document.write ('<span class="subtickertapefont">'+news[i]+'</span>')
        document.tickertape.document.subtickertape.document.close()
    }
    else
    {
        document.all.subtickertape.innerHTML=news[i]
    }
   
    if (i<news.length-1)
    i++
    else
    i=0
    setTimeout("update()",speed)
    }
   

</script>
<%' To get the content from a database, Loop through the recordset here %>

<form name="tform" id="tform">
<input type=hidden name="link1" value="<%=Link1%>">
<input type=hidden name="link2" value="<%=Link2%>">
<input type=hidden name="link3" value="<%=Link3%>">
</form>

<% 'end of loop %>

<script language="Javascript">
//default speed is 4.5 seconds
var speed = 4500

var news = new Array()

news[0] = document.forms["tform"].item("link1").value
news[1] = document.forms["tform"].item("link2").value
news[2] = document.forms["tform"].item("link3").value

i = 0

</script>

<table border=0 bgcolor="<%=TickerColor%>" cellpadding=0 cellspacing=0 width=<%=TickerWidth%>>
<tr bgcolor="<%=TickerColor%>" height=<%=TickerHeight%>>
<td bgcolor="<%=TickerColor%>">
<div id="tickertape">
    <div id="subtickertape" class="subtickertapefont">Initializing...</div>
</div>
</td>
</tr>
</table>

<!-- end of file-->


Then in the Main file just add the following in the <BODY> Tag:


<BODY Onload = "if (document.all||document.layers){regenerate2();update()}">

<!--#include File="TickerInclude.asp"-->


That's it!


blog comments powered by Disqus
ASP CODE ARTICLES

- ASP Forms
- ASP: The Beginning
- Getting Remote Files With ASP Continued
- Inbox and Outbox Manipulation in ASP
- Relational DropDownList Using VB.NET
- Ad Tracking URL Hits
- Use ViewState to display one record per page...
- Send Email using ASP.NET formatted in HTML
- ASP File Explorer
- ASP/XML Interview questions by Srivatsan Sri...
- Pressing RETURN won't submit the form
- This shows how you get the TEXT of a combo r...
- Group Data by Adrian Forbes
- Multiple checkbox select sample
- Multiple checkbox select with all values sam...

ASP Web Hosting ASP.Net Web Hosting Windows Web Hosting
 
 
 

ASP Free Forums 
 RSS  Tutorials RSS
 RSS  Forums RSS
 RSS  All Feeds
Site Map 
Request Media Kit
Write For Us Get Paid 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Privacy Policy 
Support 


© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 5 - Follow our Sitemap
Most Popular Topics
All ASP.Net Tutorials