Rotate Random Div Layers on Page Refresh?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Joey_Stacks

    Rotate Random Div Layers on Page Refresh?

    Does anyone know of a scipt that will rotate random div layers on page
    refresh? I have a primary content area front and center on my site
    homepage, and I'd like to rotate various chunks of html (in div
    layers) each time a user reloads the page. Right now I'm resorting to
    a random image rotation (those scripts are a dime a dozen) on refresh,
    but it's far from ideal for what I'm trying to accomplish. Any help
    on this would be GREATLY appreciated!

    Joey Stacks
    joey_60622@yaho o.com

  • -Lost

    #2
    Re: Rotate Random Div Layers on Page Refresh?

    "Joey_Stack s" <joey_60622@yah oo.comwrote in message
    news:1176577029 .250957.291670@ y80g2000hsf.goo glegroups.com.. .
    Does anyone know of a scipt that will rotate random div layers on page
    refresh? I have a primary content area front and center on my site
    homepage, and I'd like to rotate various chunks of html (in div
    layers) each time a user reloads the page. Right now I'm resorting to
    a random image rotation (those scripts are a dime a dozen) on refresh,
    but it's far from ideal for what I'm trying to accomplish. Any help
    on this would be GREATLY appreciated!
    Just so I can be sure of what you are asking...

    You mean rotate as in switch between say 4 current DIVs for 4 *other* DIVs or did you mean
    to rotate around something?

    I just got confused from "random image rotations" and "rotate random div layers."

    The first sounds like randomly, you turn some of the IMGs clockwise or counter- clockwise
    by 90 degrees or something.

    The second sounds to me as if you want to replace 4 DIVs for 4 DIVs (per my previous
    example), the likes of which are undetermined ("random div layers").

    -Lost


    Comment

    • Joey_Stacks

      #3
      Re: Rotate Random Div Layers on Page Refresh?

      On Apr 14, 10:26 pm, "-Lost" <missed-s...@comcast.ne twrote:
      "Joey_Stack s" <joey_60...@yah oo.comwrote in message
      >
      news:1176577029 .250957.291670@ y80g2000hsf.goo glegroups.com.. .
      >
      Does anyone know of a scipt that will rotate random div layers on page
      refresh? I have a primary content area front and center on my site
      homepage, and I'd like to rotate various chunks of html (in div
      layers) each time a user reloads the page. Right now I'm resorting to
      a random image rotation (those scripts are a dime a dozen) on refresh,
      but it's far from ideal for what I'm trying to accomplish. Any help
      on this would be GREATLY appreciated!
      >
      Just so I can be sure of what you are asking...
      >
      You mean rotate as in switch between say 4 current DIVs for 4 *other* DIVs or did you mean
      to rotate around something?
      >
      I just got confused from "random image rotations" and "rotate random div layers."
      >
      The first sounds like randomly, you turn some of the IMGs clockwise or counter- clockwise
      by 90 degrees or something.
      >
      The second sounds to me as if you want to replace 4 DIVs for 4 DIVs (per my previous
      example), the likes of which are undetermined ("random div layers").
      >
      -Lost
      I'd be happy to clarify. You know how people rotate banner ads on
      refresh? Like, at the top of a web site. Each time you refresh the
      page, a different banner ad shows up in the same spot. Sometimes
      you'll see the same banner on consecutive refreshes as the javascript
      is completely random math (I guess.) That's what I want to do, only
      with div layers. So here's what I've got going on. I'm designing a
      site, and front and center on the homepage in a 900x300 table, I want
      to rotate (on refresh) 3 seperate marketing messages with graphics and
      html text. The text has to be on top of the graphic though, thus the
      need to for div layers. Got it?

      Comment

      • Pete

        #4
        Re: Rotate Random Div Layers on Page Refresh?

        <div id="d1" style="display: none;">some text 1</div>
        <div id="d2" style="display: none;">some text 2</div>
        <div id="d3" style="display: none;">some text 3</div>

        <script type="text/javascript">
        divs = ['d1','d2','d3'];

        function hideDivs() {
        for (var i=0; i<divs.length; i++)
        document.getEle mentById(divs[i]).style.display = 'none';
        }

        function showDiv() {
        hideDivs(); //hide them all before we show the next one.
        var randomDiv = divs[Math.floor(Math .random()*divs. length)];
        var div = document.getEle mentById(random Div).style.disp lay =
        'block';

        setTimeout(show Div,500); //set a delay before showing the next div
        }

        showDiv();
        </script>


        Comment

        • Dr J R Stockton

          #5
          Re: Rotate Random Div Layers on Page Refresh?

          In comp.lang.javas cript message <1176779873.238 055.27570@w1g20 00hsg.goog
          legroups.com>, Mon, 16 Apr 2007 20:17:53, Joey_Stacks
          <joey_60622@yah oo.composted:
          Sometimes
          >you'll see the same banner on consecutive refreshes as the javascript
          >is completely random math (I guess.)
          Obviously there are two parts to the question -
          How to choose the next banner,
          How to emplace the chosen banner.

          For the first part, consider "Indefinite Random Slide Show" at
          <URL:http://www.merlyn.demo n.co.uk/js-randm.htm#IRSS- but you'll need
          to be able to preserve sufficient information between refreshes.

          It's a good idea to read the newsgroup c.l.j and its FAQ. See below.

          --
          (c) John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v6.05 IE 6
          news:comp.lang. javascript FAQ <URL:http://www.jibbering.c om/faq/index.html>.
          <URL:http://www.merlyn.demo n.co.uk/js-index.htmjscr maths, dates, sources.
          <URL:http://www.merlyn.demo n.co.uk/TP/BP/Delphi/jscr/&c, FAQ items, links.

          Comment

          • Joey_Stacks

            #6
            Re: Rotate Random Div Layers on Page Refresh?

            On Apr 17, 4:06 am, Pete <peter.gal...@g mail.comwrote:
            <div id="d1" style="display: none;">some text 1</div>
            <div id="d2" style="display: none;">some text 2</div>
            <div id="d3" style="display: none;">some text 3</div>
            >
            <script type="text/javascript">
            divs = ['d1','d2','d3'];
            >
            function hideDivs() {
            for (var i=0; i<divs.length; i++)
            document.getEle mentById(divs[i]).style.display = 'none';
            >
            }
            >
            function showDiv() {
            hideDivs(); //hide them all before we show the next one.
            var randomDiv = divs[Math.floor(Math .random()*divs. length)];
            var div = document.getEle mentById(random Div).style.disp lay =
            'block';
            >
            setTimeout(show Div,500); //set a delay before showing the next div
            >
            }
            >
            showDiv();
            </script>
            Pete, thanks for the reply! I tried your code and can't seem to get
            it to work. The text isn't showing up. I assume the script goes in
            between the <head></headtags yes? Any chance the display='block'
            has anything to do with this? Here's what I did:

            --------------------------------------------------------------------------------------------------
            >
            <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
            www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">
            <html xmlns="http://www.w3.org/1999/xhtml">
            <head>
            <meta http-equiv="Content-Type" content="text/html;
            charset=iso-8859-1" />
            <title>Untitl ed Document</title>
            <script type="text/javascript">
            divs = ['d1','d2','d3'];

            function hideDivs() {
            for (var i=0; i<divs.length; i++)
            document.getEle mentById(divs[i]).style.display = 'none';

            }

            function showDiv() {
            hideDivs(); //hide them all before we show the next one.
            var randomDiv = divs[Math.floor(Math .random()*divs. length)];
            var div = document.getEle mentById(random Div).style.disp lay =
            'block';

            setTimeout(show Div,500); //set a delay before showing the next div

            }

            showDiv();
            </script>
            </head>

            <body>

            <div id="d1" style="display: none;">some text 1</div>
            <div id="d2" style="display: none;">some text 2</div>
            <div id="d3" style="display: none;">some text 3</div>
            </body>
            </html>
            -------------------------------------------------------------------------------------------------------
            >

            Comment

            • Pete

              #7
              Re: Rotate Random Div Layers on Page Refresh?


              I intended the script to be embedded after the divs.

              If you want the js to be at the top of the page then set your body tag
              to:

              <body onload="showDiv ();">

              and remove or comment out the existing call to showDiv();

              //showDiv();
              </script>
              Pete, thanks for the reply! I tried your code and can't seem to get
              it to work. The text isn't showing up. I assume the script goes in
              between the <head></headtags yes? Any chance the display='block'
              has anything to do with this? Here's what I did:
              >

              Comment

              • Joey_Stacks

                #8
                Re: Rotate Random Div Layers on Page Refresh?

                PEte,

                It works! You are THE MAN! One more question. How would I turn off
                the auto-rotation that is built in after each page refresh? So, I
                refresh the page and I see one of the 3 divs, and it stays there until
                I refresh the page again, follow me? No auto-rotation going on
                without a page refresh. Thanks!!

                On Apr 18, 2:19 am, Pete <peter.gal...@g mail.comwrote:
                I intended the script to be embedded after the divs.
                >
                If you want the js to be at the top of the page then set your body tag
                to:
                >
                <body onload="showDiv ();">
                >
                and remove or comment out the existing call to showDiv();
                >
                //showDiv();
                </script>
                >
                Pete, thanks for the reply! I tried your code and can't seem to get
                it to work. The text isn't showing up. I assume the script goes in
                between the <head></headtags yes? Any chance the display='block'
                has anything to do with this? Here's what I did:

                Comment

                • Joey_Stacks

                  #9
                  Re: Rotate Random Div Layers on Page Refresh?

                  Pete,

                  Nevermind (maybe) about turning off the auto-rotate, I might have
                  figured it out on my own. You're probably laughing at me. How hard
                  could it be to figure it out right? ha! So, I just commented out the
                  setTimeout function, here:

                  //setTimeout(show Div,500);




                  On Apr 18, 11:57 pm, Joey_Stacks <joey_60...@yah oo.comwrote:
                  PEte,
                  >
                  It works! You are THE MAN! One more question. How would I turn off
                  the auto-rotation that is built in after each page refresh? So, I
                  refresh the page and I see one of the 3 divs, and it stays there until
                  I refresh the page again, follow me? No auto-rotation going on
                  without a page refresh. Thanks!!
                  >
                  On Apr 18, 2:19 am, Pete <peter.gal...@g mail.comwrote:
                  >
                  I intended the script to be embedded after the divs.
                  >
                  If you want the js to be at the top of the page then set your body tag
                  to:
                  >
                  <body onload="showDiv ();">
                  >
                  and remove or comment out the existing call to showDiv();
                  >
                  //showDiv();
                  </script>
                  >
                  Pete, thanks for the reply! I tried your code and can't seem to get
                  it to work. The text isn't showing up. I assume the script goes in
                  between the <head></headtags yes? Any chance the display='block'
                  has anything to do with this? Here's what I did:

                  Comment

                  • Pete

                    #10
                    Re: Rotate Random Div Layers on Page Refresh?

                    If that's the case we could simplify the code.....but hey it works
                    already.

                    On Apr 19, 1:01 pm, Joey_Stacks <joey_60...@yah oo.comwrote:
                    Pete,
                    >
                    Nevermind (maybe) about turning off the auto-rotate, I might have
                    figured it out on my own. You're probably laughing at me. How hard
                    could it be to figure it out right? ha! So, I just commented out the
                    setTimeout function, here:
                    >
                    //setTimeout(show Div,500);
                    >
                    On Apr 18, 11:57 pm, Joey_Stacks <joey_60...@yah oo.comwrote:
                    >
                    >
                    >
                    PEte,
                    >
                    It works! You are THE MAN! One more question. How would I turn off
                    the auto-rotation that is built in after each page refresh? So, I
                    refresh the page and I see one of the 3 divs, and it stays there until
                    I refresh the page again, follow me? No auto-rotation going on
                    without a page refresh. Thanks!!
                    >
                    On Apr 18, 2:19 am, Pete <peter.gal...@g mail.comwrote:
                    >
                    I intended the script to be embedded after the divs.
                    >
                    If you want the js to be at the top of the page then set your body tag
                    to:
                    >
                    <body onload="showDiv ();">
                    >
                    and remove or comment out the existing call to showDiv();
                    >
                    //showDiv();
                    </script>
                    >
                    Pete, thanks for the reply! I tried your code and can't seem to get
                    it to work. The text isn't showing up. I assume the script goes in
                    between the <head></headtags yes? Any chance the display='block'
                    has anything to do with this? Here's what I did:- Hide quoted text -
                    >
                    - Show quoted text -

                    Comment

                    • Joey_Stacks

                      #11
                      Re: Rotate Random Div Layers on Page Refresh?

                      Thanks again Pete, I'll have to email you when the demo site is live
                      so you can see your code in action...

                      On Apr 19, 7:38 pm, Pete <peter.gal...@g mail.comwrote:
                      If that's the case we could simplify the code.....but hey it works
                      already.
                      >
                      On Apr 19, 1:01 pm, Joey_Stacks <joey_60...@yah oo.comwrote:
                      >
                      Pete,
                      >
                      Nevermind (maybe) about turning off the auto-rotate, I might have
                      figured it out on my own. You're probably laughing at me. How hard
                      could it be to figure it out right? ha! So, I just commented out the
                      setTimeout function, here:
                      >
                      //setTimeout(show Div,500);
                      >
                      On Apr 18, 11:57 pm, Joey_Stacks <joey_60...@yah oo.comwrote:
                      >
                      PEte,
                      >
                      It works! You are THE MAN! One more question. How would I turn off
                      the auto-rotation that is built in after each page refresh? So, I
                      refresh the page and I see one of the 3 divs, and it stays there until
                      I refresh the page again, follow me? No auto-rotation going on
                      without a page refresh. Thanks!!
                      >
                      On Apr 18, 2:19 am, Pete <peter.gal...@g mail.comwrote:
                      >
                      I intended the script to be embedded after the divs.
                      >
                      If you want the js to be at the top of the page then set your body tag
                      to:
                      >
                      <body onload="showDiv ();">
                      >
                      and remove or comment out the existing call to showDiv();
                      >
                      //showDiv();
                      </script>
                      >
                      Pete, thanks for the reply! I tried your code and can't seem to get
                      it to work. The text isn't showing up. I assume the script goes in
                      between the <head></headtags yes? Any chance the display='block'
                      has anything to do with this? Here's what I did:- Hide quoted text -
                      >
                      - Show quoted text -

                      Comment

                      Working...