Site description randomizer Hitskin_logo Hitskin.com

This is a Hitskin.com skin preview
Install the skinReturn to the skin page

The forum of the forums
Would you like to react to this message? Create an account in a few clicks or log in to continue.
3 posters

    Site description randomizer

    Bloxx
    Bloxx
    New Member


    Posts : 6
    Reputation : 1
    Language : English

    Solved Site description randomizer

    Post by Bloxx September 21st 2016, 10:54 pm

    Hello, I am here today again to ask for help on a site description randomizer, Where the site description's text will change once a page refreshes. I have tried this code but it did not work

    Code:
    script type="text/javascript">//<![CDATA[
    (function() {
      var message = [
        'Message 1',
        'Message 2',
        'Message 3'
      ];
     
      document.write(message[Math.floor(Math.random() * message.length)]);
    })();
    //]]></script>

    I think I was using one for a different PHP. maybe a Phpbb2 or something other than Phpbb3 ( I'm using Phpbb3 by the way ) and I just couldn't get it to work.. Is this for Phpbb3? Or am I just doing something wrong?


    Last edited by Bloxx on September 21st 2016, 11:13 pm; edited 1 time in total
    SLGray
    SLGray
    Administrator
    Administrator


    Male Posts : 51498
    Reputation : 3523
    Language : English
    Location : United States

    Solved Re: Site description randomizer

    Post by SLGray September 21st 2016, 11:05 pm

    When posting codes, please use the code tags.



    Site description randomizer Slgray10

    When your topic has been solved, ensure you mark the topic solved.
    Never post your email in public.
    Ch@lo Valdez
    Ch@lo Valdez
    Forumember


    Male Posts : 138
    Reputation : 50
    Language : spanish

    Solved Re: Site description randomizer

    Post by Ch@lo Valdez September 22nd 2016, 1:29 am

    ok, remove your code and try with this:

    Code:

    $(function(){
        var a = document.getElementById('phpbb'),
        b = document.getElementById('logo-desc'),
            c = [
                'Message 1',
                'Message 2',
                'Message 3',
                'Message 4',
                'Message 5',
                'Message 6',
                'Message 7'
            ];
    a &&  b && (b.lastChild.textContent= c[Math.floor(Math.random() * c.length)]);
    });
    Bloxx
    Bloxx
    New Member


    Posts : 6
    Reputation : 1
    Language : English

    Solved Re: Site description randomizer

    Post by Bloxx September 22nd 2016, 1:46 am

    Thanks it worked! Topic Solved!
    SLGray
    SLGray
    Administrator
    Administrator


    Male Posts : 51498
    Reputation : 3523
    Language : English
    Location : United States

    Solved Re: Site description randomizer

    Post by SLGray September 22nd 2016, 3:18 am

    Problem solved & topic archived.
    Please read our forum rules: ESF General Rules



    Site description randomizer Slgray10

    When your topic has been solved, ensure you mark the topic solved.
    Never post your email in public.