Message Center: Image/Text Rotator
Dec 10, 2003
This here is a script that I've used in a few different sites, namely art/graphic/image-related sites. It's designed to rotate through banner ads, images, text, or anything else. I've tried to make it as easy to use as possible, so let me know what you think. Efficiency and functionality improvement suggestions are always welcome. =)
Documentation is available (http://www.skyzyx.com/scripts/messagecenter.php), and you can download the script with a demo page at the bottom of this post.
One thing that I built-in is a user's ability to stop the content from rotating (assuming the web designer makes the function available on his/her website), which helps to conform to the Web Content Accessibility Guidelines about "no or uncontrollable screen flickering".
/*************************************
MESSAGE CENTER 5.1
(c) 2002-03, Ryan Parman
http://www.skyzyx.com
Distributed according to SkyGPL 2.1,
http://www.skyzyx.com/license/
*************************************/
/*************************************
Updated September 2, 2003
v5.1 - Added Next() and Previous(). Also added "aliases" for many
functions to help a coder's logical naming style. Changed Resume()
into an alias for Start(). Streamlined and optimized code for efficiency.
v5.0 - Completely rewrote this script from the ground-up to be object-
oriented in nature. Implemented Algorithm's OO Timeouts. Functions
include addMessage(), start(), pause(), resume(), and clear().
*************************************/
function messageCenter(zSpanID, zDelayMS)
{
// INITIALIZATION
var spanid=zSpanID;
var delay=(zDelayMS) ? zDelayMS:4000;
var messageArray=new Array();
var count=0;
var tOut=new Timer(this);
var tOutRef, tOutRev;
var prevAcct=0;
var nextAcct=0;
// ADD A MESSAGE
// The parameter must be an HTML or text string.
this.addMessage=function(zMessage) {
messageArray[messageArray.length]=zMessage;
}
// START MESSAGE CENTER
// Usually this will be called on the onload of the BODY tag.
this.start=function() {
if (document.getElementById) {
document.getElementById(spanid).innerHTML=messageArray[count];
count++;
if (count > (messageArray.length-1)) count=0;
}
tOut.clearTimeout(tOutRev);
tOutRef=tOut.setTimeout("start", delay);
nextAcct=0;
prevAcct=0;
}
// start() aliases:
this.resume=function() { this.start(); }
// PAUSE FUNCTION
// This will pause the Message Center. Optionally, passing a String parameter will display that string while paused.
this.pause=function(stopMessage) {
this.stopMsg=(stopMessage) ? stopMessage:null;
tOut.clearTimeout(tOutRef);
if (this.stopMsg) document.getElementById(spanid).innerHTML=this.stopMsg;
}
// pause() aliases:
this.stop=function(stopMessage_stop) { this.pause(stopMessage_stop); }
// CLEAR FUNCTION
// This will stop the Message Center, and clear the element's contents.
this.clear=function() {
tOut.clearTimeout(tOutRef);
document.getElementById(spanid).innerHTML=''
count=0;
nextAcct=0;
prevAcct=0;
}
// clear() aliases:
this.end=function() { this.clear(); }
this.kill=function() { this.clear(); }
this.NoDisassembleNumberFive=function() { this.clear(); }
// NEXT FUNCTION
// This will skip to the next message, and pause the Message Center.
this.next=function() {
if (nextAcct == 0) { nextAcct=1; prevAcct=1 }
else if (nextAcct != 0) count++;
if (count > (messageArray.length-1)) count=0;
if (count < 0) count=messageArray.length-1;
tOut.clearTimeout(tOutRef);
document.getElementById(spanid).innerHTML=messageArray[count];
}
// next() aliases:
this.forward=function() { this.next(); }
this.fwd=function() { this.next(); }
// PREVIOUS FUNCTION
// This will skip to the previous message, and pause the Message Center.
this.previous=function() {
if (prevAcct == 0) { prevAcct=1; count-=2; nextAcct=1; }
else if (prevAcct != 0) count--;
if (count > (messageArray.length-1)) count=0;
if (count < 0) count=messageArray.length-1;
tOut.clearTimeout(tOutRef);
document.getElementById(spanid).innerHTML=messageArray[count];
}
// previous() aliases:
this.prev=function() { this.previous(); }
this.back=function() { this.previous(); }
}
/*************************************
Utilizes Algorithm's Timer Class for Object-Oriented timeouts
http://www.undefined.net
*************************************/
function Timer() {
this.obj = (arguments.length)?arguments[0]:window;
return this;
}
Timer.prototype.setInterval = function(func, msec) {
var i = Timer.getNew();
var t = Timer.buildCall(this.obj, i, arguments);
Timer.set[i].timer = window.setInterval(t,msec);
return i;
}
Timer.prototype.setTimeout = function(func, msec) {
var i = Timer.getNew();
Timer.buildCall(this.obj, i, arguments);
Timer.set[i].timer = window.setTimeout("Timer.callOnce("+i+");",msec);
return i;
}
Timer.prototype.clearInterval = function(i) {
if(!Timer.set[i]) return;
window.clearInterval(Timer.set[i].timer);
Timer.set[i] = null;
}
Timer.prototype.clearTimeout = function(i) {
if(!Timer.set[i]) return;
window.clearTimeout(Timer.set[i].timer);
Timer.set[i] = null;
}
Timer.set = new Array();
Timer.buildCall = function(obj, i, args) {
var t = "";
Timer.set[i] = new Array();
if(obj != window) {
Timer.set[i].obj = obj;
t = "Timer.set["+i+"].obj.";
}
t += args[0]+"(";
if(args.length > 2) {
Timer.set[i][0] = args[2];
t += "Timer.set["+i+"][0]";
for(var j=1; (j+2)<args.length; j++) {
Timer.set[i][j] = args[j+2];
t += ", Timer.set["+i+"]["+j+"]";
}
}
t += ");";
Timer.set[i].call = t;
return t;
}
Timer.callOnce = function(i) {
if(!Timer.set[i]) return;
eval(Timer.set[i].call);
Timer.set[i] = null;
}
Timer.getNew = function() {
var i = 0;
while(Timer.set[i]) i++;
return i;
}
View 1 Replies
ADVERTISEMENT
Aug 27, 2010
Im using this code to rotate images on refresh but dont know how to add links to each image, can't anyone help?
View 3 Replies
View Related
Jan 5, 2010
I am looking to include the following image rotator on a website[url]...
However I would like to automate it so that it scrolls through each image/description in an interval.
Is it possible to do with the jQuery used?
View 2 Replies
View Related
Jan 24, 2011
I'm trying to use an image rotator on a site. I've been told that we are set up to use Jquery plugins. But I'm not exactly sure what that means. Do I need to upload the jquery files to my server? Or can I just link to them? Here are the two files.
[URL]
Also, currently the rotator moves too quickly. How can I slow it down? Here's the entire script.
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript" src="http://cloud.github.com/downloads/malsup/cycle/jquery.cycle.all.latest.js"></script>
[Code].....
View 1 Replies
View Related
Nov 10, 2011
I'm trying to do a simple image rotator without a plugin (they're not letting me use a plugin, but I don't need any transition effects, so it should be very simple w/o a plugin.
[Code]...
(I also would to find an approach that I can easily choose whether or not it should loop or not (stop at last photo or go back to the first photo..)
View 2 Replies
View Related
Dec 16, 2010
I just need something that rotates/slides a few images when a page loads. I'd guess Jquery would work best? But it needs to work in all browsers, and I have read some horror stories about ones that don't. Any good recommendations?
View 1 Replies
View Related
Apr 1, 2011
I have added an image rotator to my website using Java Script.The box for the rotator shows up on the published site but not the pictures.When I click on the box it links to the pictures I have added, and I know they are rotating because it changes every time I click on it.Also, the code does not seem to be showing up when I view the source of the page.
View 6 Replies
View Related
Feb 23, 2011
im looking for an image rotator script with links, so every time the page is refreshed a new random image is displayed. The thing is, i need a script that doesnt have the location of the images in the script.I need a script like the current google adsense script, no advertisement links or locations are displayed.
View 2 Replies
View Related
Jul 1, 2010
I did a search but didn't find this so if I missed the thread I apologize. I want to show 3 images with a link to the individual dog's page. The images are rotating just fine but none of them are clickable. I'm new to Javascript and took a simple image rotator script and then edited it.
View 2 Replies
View Related
Jan 20, 2010
I found on this site very good script for rotating images in table background.[code]However, it works perfectly only in IE, while it does not work in any other browser. I understood that problem is with document.getElementById.
View 15 Replies
View Related
Apr 23, 2010
I've been working on a site that uses some JS to rotate some images near the top - the nice looking ones of the safari lodge :Which uses the code :
Code:
<script type="text/javascript">
//new fadeshow(IMAGES_ARRAY_NAME, slideshow_width, slideshow_height, borderwidth, delay,
[code]....
View 2 Replies
View Related
May 17, 2011
I am working on building a website and have been looking for a jquery plugin with no luck. I am wanting something that doesn't show anything but the image. And then after X number of seconds, the image slides UP and the next image slides up from the bottom of the frame.
This is an example of the kind of plugin I'm after.[URL]
That one shows just the image and you can control speed, but it fades in/out. I just want it to slide up!
View 2 Replies
View Related
Feb 17, 2010
New to javascript/jquery, been trying to create a rotator which displays a large image with caption and uses next/previous button and thumbnails for control. Everything works fine but when the rotator gets to the last item i'd like it to go back to the first, and when the previous button is clicked at the first item I'd like it to go to the last.
$(document).ready(function() {
//set to zero
var x = 0;
[code]....
View 1 Replies
View Related
Jul 6, 2009
I'm trying to get some thumbnail images that are displayed with ClueTip to be centered vertically & horizontally. The images are various sizes, though none is larger than 150px on a side, so I set ClueTip to have a width & height of 200px. The images are wrapped in a div so that I can have them display: none by default, yet assign display: block to the images themselves.
div.DownloadStatsThumb { display: none; vertical-align: middle; }
img.DownloadStatsThumb { display: block; margin: auto; }
The markup looks like so:
<a href="#" rel="#thumb_456" title="">foo</a>
<div class="DownloadStatsThumb" id="thumb_456">
<img src="/path/to/some/image.jpg"
width="150" height="101" alt="thumbnail image"
class="DownloadStatsThumb" />
</div>
The images are always aligned left & top. Eventually, I figured out that it was div#cluetip-inner that was the culprit. While the outer div has a height and width, the inner div has display:inline-block and so was shrinking down to the img size, essentially. I then added:
onActivate: function(e){
$('#cluetip-inner')
.css('display', 'block')
.css('width', '186px')
.css('height', '186px')
.css('vertical-align', 'middle')
.css('background-color', '#000');
return true;
}
The 186px is to avoid getting scrollbars and the BG color is to assure myself that it's resizing ok. However, the images remain centered horizontally only. Is there something else I've missed?
View 1 Replies
View Related
Nov 29, 2011
i want to do effect (overlib) like this [URL]
but i want to display image in center of screen not on right bottom corner.
View 2 Replies
View Related
May 21, 2010
Basically I have added a Lightbox gallery, which is all working as it should here URL...However, the large photos can render underneath the two sets of rotating images - the ones near the top of various resorts, and the one on the left hand side showing sponsor's logos. It only seems to do it sometimes with the set at the top, but always with the Award Sponsors one.If it doesn't show with the page as it loads, you can see what I mean by scrolling down until the Awards Sponsors graphic is about halfway down the screen.
So my question is really just to ask if there's a way of ensuring that the Lightbox photos do appear over everything else on the page?
View 2 Replies
View Related
Apr 24, 2009
For simplicity and debugging, I attempt to display an apple when the mouse passes over the center of an image.In IE, the mouseover hand shows as the mouse passes over the center of the image and the apple is displayed.In FF, the mouseover hand shows as the mouse passes over the center of the image but the apple does not display.(By the way, I'm certain the showhide function is fine,
<div id="Core" style="position:absolute; width:209px; height:115px; z-index:4; top:212px; left:28px; visibility: hidden"><font color="#000000"><img src="apple.jpg" width="125" height="140"></font></div>[code]....
View 3 Replies
View Related
Aug 9, 2010
I have a fucntion that runs after page loads which is supposed to show an image with Loading Data in Progress. Please wait message while it is pulling data. It is working in Firefox but IE is not displaying the image and the message at all. see attached working image in Firefox. My image HTML is:
<div style="display:none;width:100%;height:100%;top:0;left:0;position:absolute;background:#FFFFFF;z-Index:200;opacity:0.8;filter:alpha(opacity=80);text-align:center" id="LoadInProgress">
<table height="100%" width="100%" cellspacing="0" cellpadding="0">
<tr>
[Code]...
View 1 Replies
View Related
Feb 6, 2006
I use the code to load image:
document.getElementById("screen").src = "Images/img1.jpg";
The issue is the image's size is about 9Mb. So I want to display the waiting mess while loading. Which "event" that notify "complete loading" that I can use?
View 2 Replies
View Related
Aug 9, 2010
I have a fucntion that runs after page loads which is supposed to show an image with “Loading Data in Progress. Please wait” message while it is pulling data.t is working in Firefox but IE is not displaying the image and the message at allMy image HTML is:
Code:
<div style="display:none;width:100%;height:100%;top:0;left:0;position:absolute;background:#FFFFFF
[code]....
View 3 Replies
View Related
Feb 27, 2010
I have this alternating text box working, but I still have some problems.
when I add this line (in the style section)
textarea.test {
width: 350px;
[code].....
View 7 Replies
View Related
Jun 11, 2011
I am using a slideshow and want to basically have an 'image loading' whilst all the images load before the slideshow. Is there a way to do this? So far I have figured the best way around this is to have a GIF as a background image that says the loading message, and then once the slideshow loads over the top its fine, however im guessing this is'nt the right way to do this. I am using this slideshow set to just loop:
[URL]
I am open to using other similar slideshows if there is one more suited.
View 1 Replies
View Related
Jul 5, 2009
I've been looking all over the place in order to find a script like they use on Foliostars, where you see a sliding semi-transparant text layer over a thumbnail image when you hover. how to achieve this using JS or an Ajax framework (preferably JQuery)?
View 2 Replies
View Related
Jul 23, 2005
Alert("Please choose your favoriate");
Is there any way I can customize the alert message box and text?
View 8 Replies
View Related
Mar 30, 2011
I have the, how can I let the alert box become wider and the text message become big.
<script type="text/javascript">
$(document).ready(function() {
alert('Please dosomethin before.');
});
</script>
View 2 Replies
View Related
Aug 22, 2010
I don't know how hard this is / isn't to do, but I wondered if it is possible to use Javascript / jQuery (I have the library included on the page I need to edit) to display a message below a text input field if the field is populated.
The reason I need it is that if the user fills the field in, I would like to add an instruction message underneath the field. If the field remains empty, I don't want the text to display.
View 14 Replies
View Related