473,657 Members | 2,430 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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
jo********@yaho o.com

Apr 14 '07 #1
10 10926
"Joey_Stack s" <jo********@yah oo.comwrote in message
news:11******** **************@ 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
Apr 15 '07 #2
On Apr 14, 10:26 pm, "-Lost" <missed-s...@comcast.ne twrote:
"Joey_Stack s" <joey_60...@yah oo.comwrote in message

news:11******** **************@ 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?

Apr 17 '07 #3
<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>
Apr 17 '07 #4
In comp.lang.javas cript message <11************ *********@w1g20 00hsg.goog
legroups.com>, Mon, 16 Apr 2007 20:17:53, Joey_Stacks
<jo********@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.
Apr 17 '07 #5
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>
-------------------------------------------------------------------------------------------------------
>
Apr 18 '07 #6

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:
Apr 18 '07 #7
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:

Apr 19 '07 #8
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:

Apr 19 '07 #9
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 -

Apr 20 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
4785
by: Apostolis K. | last post by:
I include an AdRotator component but the component doesn't rotate the ads _index.asp_ <% Set objAd=Server.CreateObject("MSWC.AdRotator") vAdRotation=objAd.GetAdvertisement("ads.txt") Response.Write "<center>" & vAdRotation & "</center>" %> <html>
2
1471
by: Nick Tew | last post by:
Is there any way to post a form in a layer and have the information refresh in the same layer without refreshing the page? To explain, if i use, say, three layers (DIV layers) on a page. One is the sites menu on the left hand side (always needs to be there), one is a layer which i want the user to be able to turn on and off themselves and it has plain text in it (which i can get to do), and one is a layer with a form in it with conforms...
2
9503
by: gene | last post by:
I have some javascript code that displays random images in random places on the page by making changes to the document's css. This works in Safari and IE, but I can't get it to work on Mozilla. Using the javascript debugger, it seems that everything is working at that end, so I wonder if the problem is mozilla/css related. The live page is at http://www.smalltime.com/exhibitions/washanddry Here is the relevant html and javascript...
3
5021
by: TaTonka | last post by:
hi! how can i manage it (html or jscript with css) that everytime a user loads or refreshes a page, the page has a new bgcolor. i want to put it in a single file, so that all my pages have the same color, but after every refresh a new random one. thanx 4 your support
3
2549
by: byrd48 | last post by:
Hi, I am developing a web site which allows users to upload and share photos. I have a datalist which lists the photos and has the usual edit, update commands. Within the edititemtemplate, I have links to allow the user to rotate the photo 90 degrees left or right. After I rebind the datalist,the photo is not rotated on the web page, although it correctly rotated on the server. If I click refresh, it updates, but calling refresh causes...
6
3116
by: sales | last post by:
Hello, I am trying to get my website checkout page to rotate / take turns displaying shopping comparison engine surveys rather than display them all 4 at the same time, thus overwhelming & annoying the customer. I tried to put together some code to rotate through a Bizrate, PriceGrabber, Shopping.com and Nextag survey, I have taken the survey code the shopping comparison engines gave and tried to put it in a random number script to...
6
3216
by: swethak | last post by:
Hi, I displayed the image taken from database.How to raotate that image using javascript.plz tell that how to start the logic.plz tell that some reference websites.
1
4918
by: raghuvendra | last post by:
Hi I have a jsp page with 4 columns: namely Category name , Category order, Input field and a submit button. All these are aligned in a row. And Each Category Name has its corresponding Category order, Input field and a submit button. The Category name is being fetched from the oracle db along with the corresponding Category order. In the corresponding input field (text box) the user enters a new category order which gets stored in...
0
8392
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8726
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7320
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6163
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5632
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4151
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4301
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2726
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1944
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.