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 5 of 5
  1. #1
    Regular Coder
    Join Date
    Jul 2004
    Location
    Lebanon
    Posts
    223
    Thanks
    6
    Thanked 0 Times in 0 Posts

    scrolling marquee based on a .txt file

    I'm looking for a code like these news tickers you see on TVS nowadays at the bottom of the screen, where they show you the latest headlines.

    I want a simple scrolling marquee text that shows the text based on a txt file
    with the ability to insert an image between every line

  • #2
    Senior Coder
    Join Date
    Feb 2006
    Location
    USA
    Posts
    1,013
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You shouldn't use scrolling text on a web page for accessibility reasons.

    http://www.w3.org/TR/WAI-WEBCONTENT/#q33
    http://www.google.com/search?q=accessibility+marquee

    If you must have scrolling text, you should provide a method to stop the scrolling.
    Learn CSS. | SSI | PHP includes | X/HTML Validator | CSS validator | Dynamic Site Solutions
    Java != JavaScript && JScript != JavaScript
    Design/program for Firefox (and/or Opera), apply fixes for IE, not the other way around.

  • #3
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,642
    Thanks
    0
    Thanked 649 Times in 639 Posts
    Javascript can't read files so you will either have to convert the text file content into Javascript or set up server side processing to read the file and conert it to Javascript.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #4
    Senior Coder
    Join Date
    Mar 2005
    Location
    Portsmouth UK
    Posts
    4,535
    Thanks
    3
    Thanked 513 Times in 500 Posts
    bit rough
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/html4/loose.dtd">
    
    <html>
    
    <head>
      <title></title>
    </head>
    
    <body>
    <script language="JavaScript" type="text/javascript">
    <!--
    var TO;
    
    function Scroll(){
    
     var inner=document.getElementById('outerDisplay');
     if (parseInt(inner.style.left)>-parseInt(inner.style.width)){
      inner.style.left=(parseInt(inner.style.left)-1)+'px';
      TO=setTimeout('Scroll()',100);
     }
     else {
      inner.style.left=(0)+'px';
      Scroll();
     }
    }
    var srcFrame;
    //External content into a layer
    function loadOuter(doc) {
     srcFrame = document.getElementById("hiddenContent");
     srcFrame.src = doc;
     // workaround for missing onLoad event in IFRAME for NN6
     if (!srcFrame.onload) {
      setTimeout("transferHTML()", 1000)
     }
    }
    
    function transferHTML(){
     srcContent='';
     if (srcFrame.contentDocument){
      srcContent=srcFrame.contentDocument.getElementsByTagName("BODY")[0].innerHTML;
     }
     else if (srcFrame.contentWindow){
      srcContent=srcFrame.contentWindow.document.body.innerHTML;
     }
     document.getElementById("outerDisplay").innerHTML = srcContent;
     clearTimeout(TO);
     Scroll();
    }
    
    
    var DocAry=new Array('Test.txt','Test2.txt');
    
    function SelectList(v){
     if (v>0){
      loadOuter(DocAry[v-1]);
     }
    }
    
    //-->
    </script>
    
    
    <INPUT TYPE="button" VALUE="Test2.txt" onClick="loadOuter('Test2.txt')" >
    <br>
    
    
    
    <div  style="position:relative;overflow:hidden;width:100px;height:40px;" >
     <div id="outerDisplay" style=position:absolute;left:0px;top:0px;width:300px;>1 2 3 4 5 </div>
    </div>
    
    <iframe  id="hiddenContent" width="200" height="200" style="position:absolute;visibility:hidden;" ></iframe>
    
    </body>
    
    </html>
    Test2.txt
    Code:
    Item 11 Item 12 Item 13 Item 14 Item 15 Item 16  Item 17
    Vic

    God Loves You and will never love you less.

    http://www.vicsjavascripts.org/Home.htm

    If my post has been useful please donate to http://www.operationsmile.org.uk/

  • #5
    New to the CF scene
    Join Date
    Jul 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Is it possible scroll up? and take out the button?

    tks


  •  

    Posting Permissions

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