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!
|
| DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware. |
More ASP Code Articles More By aspfree developerWorks - FREE Tools! | Join this Rational Talks to You teleconference, featuring Paul Boustany and Mark Krasovich, to speak to the experts about becoming a Rational ClearCase power user. Get a chance to ask your questions and learn tips and tricks for using Rational ClearCase in Agile development FREE! Go There Now!
| | | | As businesses grow increasingly dependent upon Web applications to provide services to customers, employees and partners, these complex applications become more difficult to secure. Although traditional security solutions protect Internet infrastructure layers, they do not guard against HTTP and HTML attacks. Many organizations that conduct security testing still deploy applications that allow attackers to manipulate their logic and wreak havoc on their business. To mitigate this risk, development and delivery teams must address Web application security throughout the lifecycle, addressing the many layers detailed in this paper. FREE! Go There Now!
| | | | Poor Requirements Management capabilities in an Enterprise have been linked to excessive project failures, escalating IT costs, and failure to deliver competitive advantage into the marketplace. Join Brianna M Smith from IBM Rational and learn about how successful organizations align IT and Business stakeholders through collaborative processes and tools for effective requirements management, and how an integrated approach across the IT lifecycle can provide unparalleled visibility and traceability to ensure that project teams are delivering on the business vision by "doing the right things" and "doing things right." FREE! Go There Now!
| | | | Learn to enable users to both rate existing animations and to combine existing animations into new snippets. This is the third in a series of three tutorials that chronicle the building of a site that enables collaborative discussion and animation building using Domino and OpenLaszlo. FREE! Go There Now!
| | | | Download a free trial version of IBM DB2 9.5 for Linux, UNIX, and Windows. DB2 9 is the result of a five-year development project that transformed traditional (static) database technology into an interactive data server that merges the high performance and ease of use of DB2 with the self-describing benefits of XML. FREE! Go There Now!
| | | | Download a free trial version of IBM Rational Developer for System z, software that can help you deliver core development capabilities; the power of Java Platform, Enterprise Edition (Java EE); and rapid application development support to diverse enterprise application development teams. With comprehensive development tools to help create, deploy and maintain traditional enterprise and composite applications, Rational Developer for System z enables developers with different technical backgrounds to easily participate in important technology projects. FREE! Go There Now!
| | | | Visit IBM developerWorks to download a free trial version of IBM Rational Business Developer V7.1. Rational Business Developer offers rapid and simplified development of business applications and services through Enterprise Generation Language (EGL) tools, generating Java or mainframe solutions while shielding developers from technical complexities. FREE! Go There Now!
| | | | This tutorial shows new users of IBM WebSphere Business Monitor Version 6.0.2 how to perform the "Hello World" equivalent for monitoring business process applications. It is intended to help you get familiar with the capabilities of the product. FREE! Go There Now!
| | | | IBM Enterprise Modernization solutions help organizations evolve core IT systems towards modern architectures and technologies—reducing the burden of maintenance and freeing up resources to develop new business requirements and capabilities. With the IBM Enterprise Modernization Sandbox for System z you can evaluate IBM Enterprise Modernization solutions focused on five key areas: Assets, Architectures, Skills, Processes and Infrastructures, and Investment. Each solution is based upon real customer experiences and offers a proven path to get you started with your modernization projects. FREE! Go There Now!
| | | | Secure your Web applications with IBM Rational AppScan Standard Edition V7.7, previously known as Watchfire AppScan. This Web application security testing tool automates vulnerability assessments and scans and tests for common Web application vulnerabilities. Visit IBM developerWorks to download a free trial of IBM Rational AppScan Standard Edition V7.7. FREE! Go There Now!
| | | | All FREE IBM® developerWorks Tools! | |