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! | Learn field-tested SOA principles, methodology, technology and implementation from the global SOA market leader - in a new e-book by an IBM SOA expert. Written by IBM Certified SOA Solution Designer Bobby Woolf, "Exploring IBM SOA Technology & Practice" is the ultimate insider's guide to SOA - a PDF e-book packed cover to cover with IBM's specific advice on how to make your SOA implementation a success. FREE! Go There Now!
| | | | Building a software-as-a-service solution requires addressing a few key technical challenges. In this webcast, we'll focus on the role of IBM Tivoli Directory Server and WebSphere Portlet Factory in creating a Software as a Service solution. We will demonstrate how to use Tivoli Directory Server to prevent the user population of one tenant from accessing the virtual portal and portlet components of another tenant. We will also use the dynamic profile capability of WebSphere Portlet Factory to create multiple highly customized applications from one code base. 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!
| | | | Download a free trial version of IBM Rational Developer for System i V7.1, which provides a complete development environment for traditional i5/OS application development. IBM Rational Developer for System i is a new eclipse-based workstation offering for i5/OS application development that provides a comprehensive Integrated Development Environment for edit/compile/debug of traditional RPG/COBOL/C/C++ i5/OS applications. FREE! Go There Now!
| | | | Manage, govern, and share services across your organization by using WebSphere Service Registry and Repository. Follow the hands-on exercises to learn how to navigate the Web interface to publish, find, reuse, and update services. FREE! Go There Now!
| | | | Ken Krugler, co-founder of code search company Krugle, and Laura Merling, vice president of Marketing and Business Development for Krugle, join to talk about the ins and outs of code search and what it means as a new feature for developerWorks users. FREE! Go There Now!
| | | | Learn the basics of the IBM Customer Information Control System (CICS). With a hands-on exercise, learn how to get your first CICS application up and running on your desktop using TXSeries V6.1 for Windows. The tutorial shows you how to download and install a free trial version of TXSeries V6.1. FREE! Go There Now!
| | | | Regression testing -- in which code is thoroughly tested to ensure that changes have not produced unexpected results -- is an important part of any development process. But many testing environments neglect the terminal-based applications that still form the backbone of many industries. In this tutorial, you'll learn how the Rational Functional Tester Extension for Terminal-Based Applications works with other Rational Functional Tester to help test terminal-based applications quickly and easily. FREE! Go There Now!
| | | | Get a free trial download of the latest version of IBM Rational Performance Tester V7.0.1, a load and performance testing solution for teams concerned about the scalability of their Web-based applications. Combining multiple ease-of-use features with granular detail, Rational Performance Tester simplifies the test-creation, load-generation and data-collection processes that help teams ensure the ability of their applications to accommodate required user loads. FREE! Go There Now!
| | | | With IBM Rational Systems Development Solution, you can deliver products faster with higher quality. Within this kit, Read the “Model Driven Systems Development” white paper to see how to improve product quality and communication. Then check out the rest of the e-Kit to learn more about important topics that can affect the success of any software project through customer examples, tutorials, informative Webcasts, and best practices for designing, building and managing systems. From start to finish, at every stage in your projects, Rational Systems Development Solution can help your company reach its full potential. FREE! Go There Now!
| | | | All FREE IBM® developerWorks Tools! | |