Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

alternate between 3+ urls every 2 minutes

Posted on 2013-06-04
2
Medium Priority
?
175 Views
Last Modified: 2013-06-23
Hiya All

I have a need to have a page that shows a one of 3+ urls every 2 minutes.

I don't mind using iframe or having some javascript that manages the whole thing.

Ww
0
Comment
Question by:willa666
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 9

Expert Comment

by:TvMpt
ID: 39220553
Hi.
This code do what you want but needs a small changes

var d = new Date();
var t = d.getTime();
var days = Math.floor(t / (86400000));

2) put your images in an array

var imagearray = new Array('image1.jpg','image2.jpg'...);

3) use the MOD operator (%) to find the remainder when you divide days by the number of images in the array.

var i = days % imagearray.length;

4) then show the image corresponding to that value.

var img = new Image();
img.src = imagearray[i]; 

Open in new window


Just use an url array instead img's and instead 24h (86400000ms) use 3m ( 90000 )
0
 
LVL 18

Accepted Solution

by:
nap0leon earned 2000 total points
ID: 39222098
The desired behavior is slightly unclear to me...

Should the page change what a user is seeing while they are on the page?
or
Should the page show URL1 and two minutes later, if I refresh the page, show URL2, etc.?
or
From 8:00-8:02 show URL1 to everyone.  
From 8:02-8:04, show URL2 to everyone.
From 8:04-8:06, show URL3 to everyone.

If you want to rotate what the user sees while they are on the page, like a rotating banner, all you need is a timer that changes the "src" attribute of your iframe every 2 minutes.

The attached HTML page rotates three URLs every 5000 milliseconds.  Change the URLs to be the pages/images you want displayed.  Change the height and width of the iFrame to match the contents you are showing.  Change the timer interval to 2 minutes (120000 milliseconds) when you are done testing.

(if you are actually rotating images, then you don't need an iframe, you can update the src attribute of the image on your page)
Q-28147461.html
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question