Not signed in (Sign In)

SkillShare - A place to discuss Web Standards and Web Design topics

Categories

Vanilla 1.1.9 is a product of Lussumo. More Information: Documentation, Community Support.

    • CommentAuthorkonitz
    • CommentTimeAug 11th 2006
     permalink
    any javascript or something to change text every some seconds... i cant find a example...
    thanks
    • CommentAuthorvarland
    • CommentTimeAug 11th 2006
     permalink
    Your best bet is probably the setTimeout function. There are references all over the web.
    •  
      CommentAuthorpremii
    • CommentTimeAug 12th 2006
     permalink
    use setInterval
    syntax:

    var t = setInterval(function(){document.body.innerHTML = new Date().getTime();}, 5000);
    • CommentAuthorvarland
    • CommentTimeAug 13th 2006
     permalink
    setInterval is the one I was thinking of. Sorry about the confusion.
    • CommentAuthorkonitz
    • CommentTimeAug 13th 2006
     permalink
    hi, i use the syntax, the text change but where put the text that i want to change, when change... change some numbers like this: 1155496712107 etc....... help me!!!
    •  
      CommentAuthorJohnRiv
    • CommentTimeAug 13th 2006 edited
     permalink
    premii's script will display the number of milliseconds since THE epoch (which was midnight on January 1, 1970) and update the number every 5 seconds (5000 milliseconds).

    what is the text you want to change and what do you want to change it to?
    • CommentAuthorkonitz
    • CommentTimeAug 14th 2006
     permalink
    thanks JohnRiv in mean change by example this:

    New Release... Leopard
    Ten Reason to Buy Gumballs
    White House bla bla

    i mean first one new, later dissapear and come the second in the same position... etc...

    thanks
    •  
      CommentAuthorJohnRiv
    • CommentTimeAug 14th 2006 edited
     permalink
    <html>
    <head>
    <title>Rotating Text</title>
    <script type="text/javascript">
    var rotatingTextElement;
    var rotatingText = new Array();
    var ctr = 0;

    function initRotateText() {
    rotatingTextElement = document.getElementById("textToChange");
    rotatingText[0] = rotatingTextElement.innerHTML; // store the content that's already on the page
    rotatingText[1] = "Ten Reason to Buy Gumballs";
    rotatingText[2] = "White House bla bla";
    setInterval(rotateText, 5000);
    }
    function rotateText() {
    ctr++;
    if(ctr >= rotatingText.length) {
    ctr = 0;
    }
    rotatingTextElement.innerHTML = rotatingText[ctr];
    }
    window.onload = initRotateText;
    </script>
    </head>
    <body>
    <span id="textToChange">New Release... Leopard</span>
    </body>
    </html>
    • CommentAuthorkonitz
    • CommentTimeAug 14th 2006
     permalink
    Wow You Rocks Jonh Riv... Amazing thanks a lot!!!!! works perfect! :)
    •  
      CommentAuthorJohnRiv
    • CommentTimeAug 14th 2006
     permalink
    Glad to help. One thing I do want to point out is that I used innerHTML rather than "real" W3C DOM methods because it's faster... see http://www.quirksmode.org/dom/innerhtml.html for more info
    • CommentAuthorkonitz
    • CommentTimeAug 14th 2006 edited
     permalink
    thanks John look this, I need put links to the messages... I can only put to the first one... the others I cant!. please help me! thanks a lot!

    the html:
    --------------------------------
    <span id="textToChange"><a href="#">Nuevo disco HIM Dark Light producido por Roger Dean a la venta el 30 de Mayo</a></span>


    the java:
    --------------------------------
    var rotatingTextElement;
    var rotatingText = new Array();
    var ctr = 0;

    function initRotateText() {
    rotatingTextElement = document.getElementById("textToChange");
    rotatingText[0] = rotatingTextElement.innerHTML; // store the content that's already on the page
    rotatingText[1] = "Bauhaus DVD Shadow Light";
    rotatingText[2] = "Remaster The Clash - London Calling 4 CDs Box Set";
    rotatingText[3] = "The Cure 2CDs Greatest Hits";
    setInterval(rotateText, 6000);
    }
    function rotateText() {
    ctr++;
    if(ctr >= rotatingText.length) {
    ctr = 0;
    }
    rotatingTextElement.innerHTML = rotatingText[ctr];
    }
    window.onload = initRotateText;
    • CommentAuthorPettyRider
    • CommentTimeAug 15th 2006 edited
     permalink
    Put the hyperlink ANCHORs in your `rotatingText` array.

    rotatingText[1] = "<a href=\"bauhaus.htm\">Bauhaus DVD Shadow Light</a>";
    ...

    Be sure to escape the attribute quotes in the array values.

    I think this will work, using the non-standard innerHTML property in your code. I could be wrong.
    • CommentAuthorkonitz
    • CommentTimeAug 15th 2006
     permalink
    wow PettyRider, that works!!! thanks you are not wrong... cool thanks to all guys!!!
    • CommentAuthorponder
    • CommentTimeFeb 3rd 2010
     permalink
    hi friends
    <html>
    <head>
    <title>Rotating Text</title>
    <script type="text/javascript">
    var rotatingTextElement;
    var rotatingText = new Array();
    var ctr = 0;

    function initRotateText() {
    rotatingTextElement = document.getElementById("textToChange");
    rotatingText[0] = rotatingTextElement.innerHTML; // store the content that's already on the page
    rotatingText[1] = "Ten Reason to Buy Gumballs";
    rotatingText[2] = "White House bla bla";
    setInterval(rotateText, 5000);
    }
    function rotateText() {
    ctr++;
    if(ctr >= rotatingText.length) {
    ctr = 0;
    }
    rotatingTextElement.innerHTML = rotatingText[ctr];
    }
    window.onload = initRotateText;
    </script>
    </head>
    <body>
    <span id="textToChange">New Release... Leopard</span>
    </body>
    </html>


    the above code is working fine,, but i need the above program for n number...

    its possible to do?????
Add your comments
    Username Password
  • Format comments as (Help)