premshree
07-29-2003, 07:04 PM
The above is a XML based JavaScript Ticker using the XML Data Source Object (DSO).
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>XML Ticker using XML DSO</title>
<!-- begin style -->
<style type="text/css">
.tickerStyle {
font-family:verdana,arial,helvetica; font-size:10pt; color:#666666; border:#666666 solid 1px; width:100%; height:20px; text-decoration:none; text-align:center; background:#FFFFFF
}
.tickerStyle:hover {
font-family:verdana,arial,helvetica; font-size:10pt; color:#FF6600; border:#666666 solid 1px; width:100%px; height:20px; text-decoration:none; text-align:center; background:#FFFFFF
}
body{font-family:verdana,arial,helvetica}
td{font-size:10pt}
a{font-family:verdana,arial,helvetica; color:#666666; font-size:10pt}
a:hover{font-family:verdana,arial,helvetica; color:#FF6600; font-size:10pt}
hr{color:#CCCCCC; height:1px}
</style>
<!-- end style -->
<!-- begin script -->
<script language="JavaScript">
//////////////////////////////////////////////////
// XML Ticker using XML DSO //
// by Premshree Pillai //
// http://www.qiksearch.com //
// http://premshree.resource-locator.com //
//////////////////////////////////////////////////
var xmlDso, tickerSet;
function initTicker(xmlFile, objName, counter, maxMsgs, timeOut) {
if(document.all&&navigator.userAgent.indexOf("Opera")==-1) {
eval('xmlDso='+objName+'.XMLDocument');
xmlDso.load(xmlFile);
setTimeout("xmlDsoTicker('"+objName+"','"+counter+"','"+maxMsgs+"','"+timeOut+"')", timeOut);
}
else {
alert('This Ticker works with IE4+ only!');
return false;
}
}
function xmlDsoTicker(objName, counter, maxMsgs, timeOut) {
eval('tickerSet=' + objName + '.recordset');
if(!tickerSet.EOF && counter<maxMsgs-1) {
tickerSet.MoveNext();
counter++;
}
else {
counter=0;
tickerSet.MoveFirst();
}
setTimeout("xmlDsoTicker('"+objName+"','"+counter+"','"+maxMsgs+"','"+timeOut+"')", timeOut);
}
</script>
<!-- end script -->
</head>
<body bgcolor="#FFFFFF">
<table width="450" align="center"><tr><td>
<!-- begin ticker placement -->
<center>
<object id="ticker" CLASSID="clsid:550dda30-0541-11d2-9ca9-0060b0ec3d39" width="0" height="0"></object>
<a href="" datasrc="#ticker" datafld="URL" class="tickerStyle">
<span datasrc="#ticker" datafld="message"></span>
</a>
<script language="JavaScript">
var tickerMaxMsgs=3; // Maximum Messages in the XML Data file
var tickerCount=tickerMaxMsgs;
new initTicker("ticker_items.xml","ticker",tickerCount,tickerMaxMsgs,2000); // Set the Ticker
</script>
</center>
<!-- end ticker placement -->
</td></tr></table>
</body>
</html>
See example here: http://www.premshree.resource-locator.com/javascripts/xml/ticker/xml-dso/ticker.htm
IE only.
:thumbsup:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>XML Ticker using XML DSO</title>
<!-- begin style -->
<style type="text/css">
.tickerStyle {
font-family:verdana,arial,helvetica; font-size:10pt; color:#666666; border:#666666 solid 1px; width:100%; height:20px; text-decoration:none; text-align:center; background:#FFFFFF
}
.tickerStyle:hover {
font-family:verdana,arial,helvetica; font-size:10pt; color:#FF6600; border:#666666 solid 1px; width:100%px; height:20px; text-decoration:none; text-align:center; background:#FFFFFF
}
body{font-family:verdana,arial,helvetica}
td{font-size:10pt}
a{font-family:verdana,arial,helvetica; color:#666666; font-size:10pt}
a:hover{font-family:verdana,arial,helvetica; color:#FF6600; font-size:10pt}
hr{color:#CCCCCC; height:1px}
</style>
<!-- end style -->
<!-- begin script -->
<script language="JavaScript">
//////////////////////////////////////////////////
// XML Ticker using XML DSO //
// by Premshree Pillai //
// http://www.qiksearch.com //
// http://premshree.resource-locator.com //
//////////////////////////////////////////////////
var xmlDso, tickerSet;
function initTicker(xmlFile, objName, counter, maxMsgs, timeOut) {
if(document.all&&navigator.userAgent.indexOf("Opera")==-1) {
eval('xmlDso='+objName+'.XMLDocument');
xmlDso.load(xmlFile);
setTimeout("xmlDsoTicker('"+objName+"','"+counter+"','"+maxMsgs+"','"+timeOut+"')", timeOut);
}
else {
alert('This Ticker works with IE4+ only!');
return false;
}
}
function xmlDsoTicker(objName, counter, maxMsgs, timeOut) {
eval('tickerSet=' + objName + '.recordset');
if(!tickerSet.EOF && counter<maxMsgs-1) {
tickerSet.MoveNext();
counter++;
}
else {
counter=0;
tickerSet.MoveFirst();
}
setTimeout("xmlDsoTicker('"+objName+"','"+counter+"','"+maxMsgs+"','"+timeOut+"')", timeOut);
}
</script>
<!-- end script -->
</head>
<body bgcolor="#FFFFFF">
<table width="450" align="center"><tr><td>
<!-- begin ticker placement -->
<center>
<object id="ticker" CLASSID="clsid:550dda30-0541-11d2-9ca9-0060b0ec3d39" width="0" height="0"></object>
<a href="" datasrc="#ticker" datafld="URL" class="tickerStyle">
<span datasrc="#ticker" datafld="message"></span>
</a>
<script language="JavaScript">
var tickerMaxMsgs=3; // Maximum Messages in the XML Data file
var tickerCount=tickerMaxMsgs;
new initTicker("ticker_items.xml","ticker",tickerCount,tickerMaxMsgs,2000); // Set the Ticker
</script>
</center>
<!-- end ticker placement -->
</td></tr></table>
</body>
</html>
See example here: http://www.premshree.resource-locator.com/javascripts/xml/ticker/xml-dso/ticker.htm
IE only.
:thumbsup: