Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder Skyzyx's Avatar
    Join Date
    Aug 2002
    Location
    Silicon Valley, CA
    Posts
    980
    Thanks
    0
    Thanked 0 Times in 0 Posts

    A JavaScript Ticker

    Code:
    <!--
    ********************************
    Message Center 4.0
    Designed for older browsers.
    By Skyzyx Genesis
    ********************************
    -->
    
    <html>
    <head>
    <title>
    Message Center 4.0
    </title>
    <script language="javascript">
    <!--
    
    // Basic Configuration
    var zDelay=4000;
    var zCurrMsg=0;
    var zContents=new Array;
    
    // Site Switcher
    var site=1;
    
    if (site==1)
    {
    	// Messages
    	zContents[0]="This is site 1 message 1";
    	zContents[1]="This is site 1 message 2";
    	zContents[2]="This is site 1 message 3";
    	zContents[3]="This is site 1 message 4";
    	zContents[4]="This is site 1 message 5";
    }
    else if (site==2)
    {
    	// Messages
    	zContents[0]="This is site 2 message 1";
    	zContents[1]="This is site 2 message 2";
    	zContents[2]="This is site 2 message 3";
    	zContents[3]="This is site 2 message 4";
    	zContents[4]="This is site 2 message 5";
    }
    else if (site==3)
    {
    	// Messages
    	zContents[0]="This is site 3 message 1";
    	zContents[1]="This is site 3 message 2";
    	zContents[2]="This is site 3 message 3";
    	zContents[3]="This is site 3 message 4";
    	zContents[4]="This is site 3 message 5";
    }
    else if (site==4)
    {
    	// Messages
    	zContents[0]="This is site 4 message 1";
    	zContents[1]="This is site 4 message 2";
    	zContents[2]="This is site 4 message 3";
    	zContents[3]="This is site 4 message 4";
    	zContents[4]="This is site 4 message 5";
    }
    
    function zMessageCenter()
    {
    	var zMessages=zContents.length;
    
    	if (document.getElementById)
    	{
    		zMCID=document.getElementById("ShowMessageCenter");
    		zMCID.innerHTML=zContents[zCurrMsg];
    	}
    
    	// MESSAGE COUNTER
    	if (zCurrMsg == (zMessages-1)) zCurrMsg=0;
    	else zCurrMsg++;
    
    	setTimeout("zMessageCenter()", zDelay)
    }
    //-->
    </script>
    </head>
    <body>
    <span style="font-family:Verdana; font-size:16pt; color:#0066FF; font-weight:bold;" id="ShowMessageCenter"></span>
    <script language="javascript">
    <!--
    zMessageCenter();
    //-->
    </script>
    </body>
    </html>

    Creator of SimplePie and Tarzan AWS, co-founder of WarpShare, co-built the Y! Messenger website, usability-focused, and an INFJ personality.

  • #2
    Regular Coder Skyzyx's Avatar
    Join Date
    Aug 2002
    Location
    Silicon Valley, CA
    Posts
    980
    Thanks
    0
    Thanked 0 Times in 0 Posts

    XML-Based Ticker

    The XML file is set up like so...
    Code:
    <?xml version="1.0"?>
    
    	<MESSAGES>
    		<SITE>
    			<CONTENT>This is site 1 message 1</CONTENT>
    			<CONTENT>This is site 1 message 2</CONTENT>
    			<CONTENT>This is site 1 message 3</CONTENT>
    			<CONTENT>This is site 1 message 4</CONTENT>
    			<CONTENT>This is site 1 message 5</CONTENT>
    		</SITE>
    		<SITE>
    			<CONTENT>This is site 2 message 1</CONTENT>
    			<CONTENT>This is site 2 message 2</CONTENT>
    			<CONTENT>This is site 2 message 3</CONTENT>
    			<CONTENT>This is site 2 message 4</CONTENT>
    			<CONTENT>This is site 2 message 5</CONTENT>
    		</SITE>
    		<SITE>
    			<CONTENT>This is site 3 message 1</CONTENT>
    			<CONTENT>This is site 3 message 2</CONTENT>
    			<CONTENT>This is site 3 message 3</CONTENT>
    			<CONTENT>This is site 3 message 4</CONTENT>
    			<CONTENT>This is site 3 message 5</CONTENT>
    		</SITE>
    		<SITE>
    			<CONTENT>This is site 4 message 1</CONTENT>
    			<CONTENT>This is site 4 message 2</CONTENT>
    			<CONTENT>This is site 4 message 3</CONTENT>
    			<CONTENT>This is site 4 message 4</CONTENT>
    			<CONTENT>This is site 4 message 5</CONTENT>
    		</SITE>
    	</MESSAGES>
    Meanwhile, the webpage goes something like this...
    Code:
    <!--
    ********************************
    XML Message Center 1.0
    Designed for newer browsers.
    By Skyzyx Genesis
    ********************************
    -->
    
    <html>
    <head>
    <title>
    XML Message Center 1.0
    </title>
    
    <script language="javascript" type="text/javascript">
    <!--
    /*************************************
    DECLARE GLOBAL VARIABLES
    *************************************/
    var XMC = new Object(); // Do Not Change or Alter
    var xml_doc; // Do Not Change or Alter
    
    
    /*************************************
    BASIC SETUP/CONFIGURATION
    *************************************/
    // The first site is 1, the second site is 2, etc.
    XMC.Site=1;
    
    // The delay between messages
    var zDelay=4000;
    
    // This will determine on which message the 
    // ticker will start at.  Default is zero.
    var zCurrMsg=0;
    
    
    /*************************************
    MESSAGE CENTER FUNCTION
    *************************************/
    function zMessageCenter()
    {
    	// ROOT VALUE
    	var xmcSite = xml_doc.getElementsByTagName('SITE')[XMC.Site-1];
    	var xmcContent = xmcSite.getElementsByTagName('CONTENT');
    
    	// W3C COMPLIANCE
    	if (document.getElementById)
    	{
    		zMCID=document.getElementById("ShowMessageCenter");
    		zMCID.innerHTML=xmcContent[zCurrMsg].firstChild.data;
    	}
    
    	// MESSAGE COUNTER
    	if (zCurrMsg == xmcContent.length-1) zCurrMsg=0;
    	else zCurrMsg++;
    
    	setTimeout("zMessageCenter()", zDelay)
    }
    
    
    /*************************************
    This function loads the file.
    *************************************/
    function importXML(zFileName)
    {
    	var moz = (typeof document.implementation != 'undefined') && (typeof document.implementation.createDocument != 'undefined');
    	var ie = (typeof window.ActiveXObject != 'undefined');
    
    	if (moz)
    	{
    		xml_doc = document.implementation.createDocument("", "", null)
    		xml_doc.onload = zMessageCenter;
    	}
    
    	else if (ie)
    	{
    		xml_doc = new ActiveXObject("Microsoft.XMLDOM");
    		xml_doc.onreadystatechange = function()
    		{
    			if (xml_doc.readyState == 4) setTimeout(zMessageCenter,0);
    		}
    	}
    
    	xml_doc.load(zFileName);
    }
    
    
    /*************************************
    IMPORT THE XML DOCUMENT
    This will also start the ticker.  You no longer 
    need to manually start it.
    *************************************/
    importXML('messages.xml');
    
    
    //-->
    </script>
    </head>
    <body>
    <span style="font-family:Verdana; font-size:16pt; color:#0066FF; font-weight:bold;" id="ShowMessageCenter"></span>
    </body>
    </html>

    Creator of SimplePie and Tarzan AWS, co-founder of WarpShare, co-built the Y! Messenger website, usability-focused, and an INFJ personality.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •