JavaScript - Timed Rotation
**Solved**
Similar TutorialsI want to display a different adsence add each time my page is refreshed. How could this be acomplished? Is there existing banner rotation scripts at allow you to inser scripts instead of images and links. The scripts I need to rotate look like this. add 1 <script type="text/javascript"><!-- google_ad_client = "ca-pub-00000000000000"; /* 468x60, created 8/18/10 */ google_ad_slot = "00000000000"; google_ad_width = 468; google_ad_height = 60; //--> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script> add 2 <script type="text/javascript"><!-- google_ad_client = "ca-pub-00000000000000"; /* 468x60, created 8/18/10 */ google_ad_slot = "00000000000"; google_ad_width = 468; google_ad_height = 60; //--> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script> I once bought some plans on the net and was sent a link that said I could open so many times or for 1 week, I cant remember exactly. But now I am doing a web site and need a link like that any ideas. I would prefer it to open only so many times.
Folks I'm so in the dark about this that I couldn't even think of a sensible title for the thread! One of my colleagues reckons that some years ago she worked on a website that contained images that were set to be visible to users only between certain dates (different dates for different images, so an image representing January would be visible only during January, and so on). Does this sound like something familiar? If so, would it be done using Javascript? Thanks Remster I need an timed button. When you come to site, you must wait in that site ?? seconds and then button comes pressable.
Hi everyone! I'm new to this forum for posting, but i've been reading threads on this site for a few months now.. seems like a decent place to get info... so, hello everyone! My name's Will, (musical moniker on soundcloud / fb etc is StrangeFlow, i make electronic music, funk, hip hop, etc... ) ..I'm 25, I'm in Lansing , Michigan, my hometown (but still have residency in NorCal, where Im trying to get back to in a few months) I have some experience programming but i'm sure not as much as some of the experts on here i dont know if it's bad etiquette to post a question in my first thread but i have a good question that hasn't been able to get resolved, and I figured someone on here might have some good advice.. Does anyone on here use soundcloud? they have a really nifty timed-comments bar, you can check it out on any soundcloud music page... Ive started seeing it on vimeo recently, I think it's something thats starting to catch on. Anyway,, I had an idea for a website, but the thing is, it would require a timed-comments bar. But.. my problem is, since I'm not as much of an expert as some of the people on here, what would it take to program it? I'm learning some C#, and I heard it would be that or php.. but.. I don't know.. any advice on that timed comments thing? Any good points in the right direction would be extremely appreciated! Thanks everyone! I look forward to posting more in the future on this forum, and I'll gladly offer any of my advice on topics I am knowledgable. -StrangeFlow Dear all, I'm trying to use Javascript to have an array of images that load randomly AND work in a slideshow manner so change every 3 seconds (in a logical order). The code I have below presents a random image but how do I get them to continue from the random image and change to the next every 3 seconds? Code: <script language="JavaScript"> images = new Array(3); images[0] = "<a href = 'photo1.html'><img src='images/photo1.jpg' alt='Photo 1'></a>"; images[1] = "<a href = 'photo2.html'><img src='images/photo2.jpg' alt='Photo 2'></a>"; images[2] = "<a href = 'photo3.html'><img src='images/photo3.jpg' alt='Photo 3'></a>"; index = Math.floor(Math.random() * images.length); document.write(images[index]); </script> Kind regards Jon Hi, I need some help with my code for background image and title rotation! I'd like to get images one, two and three to rotate every one second, and have titles change according to the images. Currently both background and titles are not rotating.. ;-; Code: <script> window.onload = rotate; var adImages = new Array('one.jpg','two.jpg','three.jpg'); var titleImages = new Array('title1','title2,'title3'); var thisAd = 0; function rotate() { thisAd++; if (thisAd == adImages.length) { thisAd = 0; } document.getElementById("picture1").style.backgroundImage = "url(adImages[thisAd])"; document.getElementById("picture1").title = titleImages[thisAd]; setTimeout("rotate()", 1 * 1000); } </script> And here's my HTML Code: <div id="picture1" style="background-image:url(one.jpg);"></div> And here's my css Code: #picture1{ background-image: url(one.jpg);} Hi All! I'm new to the forums but discovered this site while looking for a solution to my javascript problem. I was able to find/manipulate the following code for changing a banner when a person mouse-overs a button. It is almost exactly what I want it to do, except that I'd like the following functionality to be added to it: 1) When a person hovers over a button, the image that appears should be clickable and open a webpage. 2) I would like to have the banners cycle/rotate by default until a person hovers over a button. When they hover, it should stop the cycle/rotation. Here is an example of what the code produces prior to my desired tweaks above: http://javascript.internet.com/image...e-gallery.html Here is the code I currently have: Code: <html> <head> <script language="JavaScript"> function update(url,index,isSuper) { document['PhotoBig'].src=url; } </script> </head> <body> <div style="margin-left: 30%;"> <table cellpadding="0" cellspacing="0" border="0" width="234"> <tr> <td colspan="8"><img src="images/hipaa-logo.png" name="PhotoBig"></td> </tr> <tr> <td colspan="8"><img src="images/w_spacer.gif" width="1" height="5"></td> </tr> <tr> <td width="120"> </td> <td width="24"><a onMouseOver="update('images/alz-logo.png', 0, false); return false;"><img src="images/button1.png"></a></td> <td width="21"><a onMouseOver="update('images/ecomm-logo.png', 1, true); return false;"><img src="images/button2.png"></a></td> <td width="21"><a onMouseOver="update('images/facebook-logo.png', 2, true); return false;"><img src="images/button3.png"></a></td> <td width="21"><a onMouseOver="update('images/hipaa-logo.png', 3, true); return false;"><img src="images/button4.png"></a></td> <td width="27"><a onMouseOver="update('images/swain-logo.png', 4, true); return false;"><img src="images/button5.png"></a></td> </tr> </table> </div> </body> </html> Any suggestions would be GREATLY appreciated! Thanks! jstwondrng Would really appreciate any help with my request.... Im looking to setup a project for my uni assignment. its going to be a time radio site and i'm looking to create a page that has some javascript to carry out an image rotation. I want to have: - three images side by side - all images to rotate from a folder containing 100+ pictures - they all have different file names and extensions but i can change them if need be - i want the images to rotate automatically without the page having to be reloaded or mouseovers or anything - i would like them to rotate on different time frames i.e. first picture 3 sec rotation, second picture 5 seconds, third image 7 seconds.... something like that if any can help me with this i would be really grateful... iv tried scanning the web but come up short. cant use php or anything its got to be a html page using javascript. just to point out im not cheating by the way the module im doing it for is for media design not programming just cant find the code to do what i want. again thanks for everyones time cheers Hi guys, I am building my second site, this time with wordpress, for a friend's restaurant. I want to use a javascript rotating banner and so I found this nice little bit of code that does the job: http://budstechshed.com/dynamic-head...rdpress-theme/ Main code Code: <?php wp_enqueue_script('jquery'); ?> <script type="text/javascript"> counter = 1; num_images = 5; // Enter the number of images to rotate dir = "<?php bloginfo('template_url'); ?>/images/headers"; // This is where your images are stored function rotateHeader() { var header_img = 'url(' + dir + '/header_' + counter + '.jpg)'; // jpg, png, or gif jQuery('.art-Header-jpeg').css('background-image', header_img); // .art-Header-jpeg is the div you want to replace counter++; if (counter > num_images) counter = 1; } </script> I have it working fine, but the code does not fade the images, which is what I require. So, is there anyway I can change this code in order to make the images fade in/out between transition? Many thanks in advance, anyone who can help and lives in Kent or London, UK can get a free curry as a thank you I'm in search for a simple and clean timed rotation script. I have these quotes, and right now they're coded so that a single quote displays and changes upon refresh. The script is really clean, and I would like to maintain the cleanliness but make the images rotate every couple of seconds. Here's the script... Code: <script type="text/javascript"> quote = new Array(3); quote[0] = "Quote 1"; quote[1] = "Quote 2"; quote[2] = "Quote 3"; index = Math.floor(Math.random() * quote.length); document.write(quote[index]); </script> It's probably a really simple piece of coding, but I'm still new to JavaScript, so it's obviously out of my range. I appreciate anyone who will help I created a drawEllipse function for a Canvas library I'm making, and it works fine in Safari, Firefox, and Chrome, but in Opera, the rotation doesn't work. The function is as follows: Code: ctx.drawEllipse = function (fill, x, y, rad1, rad2, r) { ctx.save(); if (r) { ctx.translate(x, y); ctx.rotate(r); ctx.translate(-x, -y); } ctx.scale(rad1, rad2); ctx.beginPath(); ctx.arc()(x / rad1, y / rad2, 1); ctx[fill](); ctx.restore(); }; When I add rotation to the ellipse, in Opera, it doesn't rotate and just gets bigger. I have no idea why. Can anyone suggest anything? Thanks, Julian Hi guys! I need your help so much. I have this beautiful script for pocket pc that randomly rotates pictures in the background with fade in/out effect. Now, what I want it to do is to split all the pictures I have in groups so that on every refresh the script randomly chose a GROUP of pictures and THEN rotated only the pictures from this group. I want to do this because if you include say 30 pictures into the script this really hangs the RAM memory, and if there are only 5 pictures to choose from its much more faster. Here's the script from html page: Code: <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <style> body { background-color: white; margin: 0; padding: 0; } img { -webkit-transition-property: opacity; -webkit-transition-duration: 3s; position: absolute; width: 320px; height: auto; } img.fade-out { opacity: 0; } img.fade-in { opacity: 1; } </style> </head> <body style="color: black"> <img src="01.jpg"/> <img src="02.jpg"/> <img src="03.jpg"/> <img src="04.jpg"/> <img src="05.jpg"/> <img src="06.jpg"/> <img src="07.jpg"/> <img src="08.jpg"/> <img src="09.jpg"/> <img src="10.jpg"/> <img src="11.jpg"/> <img src="12.jpg"/> <img src="13.jpg"/> <img src="14.jpg"/> <img src="15.jpg"/> <script> var interval = 4 * 1; // Seconds between change var images = document.getElementsByTagName("img"); var imageArray = []; var imageCount = images.length; var current = 0; var randomize = function(){ return (Math.round(Math.random() * 3 - 1.5)); } for(var i = 0; i < imageCount; i++){ images[i].className = 'fade-out'; imageArray[i] = images[i]; } imageArray.sort(randomize); var fade = function(){ imageArray[current++].className = 'fade-out'; if(current == imageCount){ current = 0; imageArray.sort(randomize); } imageArray[current].className = 'fade-in'; setTimeout(fade, interval * 1000); }; fade(); </script> </body> So here you can see there are 15 pictures, what should I include in this script to split them into say 3 groups of 5 pictures and make the script randomly select a group each time? Thanks for help! Hey guys, Right now I have a random rotating slideshow with delay script implemented on a website. However I want to make ONE of the slides/images clickable to open up a PDF doc. Can you please let me know what I need to add/change in this to make it do what I need? I am not big on java so need some help. Thanks in advance! Code: <script language="javascript"> /* Random image slideshow- By Tyler Clarke (tyler@ihatecoffee.com) For this script and more, visit http://www.javascriptkit.com */ var delay=12000 //set delay in miliseconds var curindex=0 var randomimages=new Array() randomimages[0]="images/simple_img_11.jpg" randomimages[1]="images/simple_img_2.jpg" randomimages[2]="images/simple_img_3.jpg" randomimages[3]="images/simple_img_4.jpg" randomimages[4]="images/simple_img_5.jpg" randomimages[5]="images/simple_img_6.jpg" randomimages[5]="images/simple_img_7.jpg" var preload=new Array() for (n=0;n<randomimages.length;n++) { preload[n]=new Image() preload[n].src=randomimages[n] } document.write('<img name="defaultimage" src="'+randomimages[Math.floor(Math.random()*(randomimages.length))]+'">') function rotateimage() { if (curindex==(tempindex=Math.floor(Math.random()*(randomimages.length)))){ curindex=curindex==0? 1 : curindex-1 } else curindex=tempindex document.images.defaultimage.src=randomimages[curindex] } setInterval("rotateimage()",delay) </script> First off, i have no idea what to do, because when i get beyond the realm of html/css, vb and php (some) i become lost. I hope someone can help me achieve this because i have no idea what i'm doing, and I've been at it for 2 weeks and no money to hire someone to do this for me. If you ever been in my situation, you know exactly how i feel. I have no code of my own to show you, but hope someone can still help me. I'm have a number 0.0000000, and every min i need that number to increase to 0.0000000, than to 0.0000002 and so on and so forth. Every time i click a button, whatever the number has risen to, it will reset it back down to 0.0000000. Can someone help me out with this? Hello, I am trying to create an image carousel for the website found here. As you can see everything works fine, however, I would like it to automatically scroll through the images every X seconds. I did not write this script (the credits are still in tact) and I know very very little about writing javascript, so I am hoping someone here can help. Thank you in advance for any replies and any suggestions/tips to making it a better script. The .js file: Code: /** * @author Bruno Bornsztein <bruno@missingmethod.com> * @copyright 2007 Curbly LLC * @package Glider * @license MIT * @url http://www.missingmethod.com/projects/glider/ * @version 0.0.3 * @dependencies prototype.js 1.5.1+, effects.js */ /* Thanks to Andrew Dupont for refactoring help and code cleanup - http://andrewdupont.net/ */ Glider = Class.create(); Object.extend(Object.extend(Glider.prototype, Abstract.prototype), { initialize: function(wrapper, options){ this.scrolling = false; this.wrapper = $(wrapper); this.scroller = this.wrapper.down('div.scroller'); this.sections = this.wrapper.getElementsBySelector('div.section'); this.options = Object.extend({ duration: 1.0, frequency: 3 }, options || {}); this.sections.each( function(section, index) { section._index = index; }); this.events = { click: this.click.bind(this) }; this.addObservers(); if(this.options.initialSection) this.moveTo(this.options.initialSection, this.scroller, { duration:this.options.duration }); // initialSection should be the id of the section you want to show up on load if(this.options.autoGlide) this.start(); }, addObservers: function() { var controls = this.wrapper.getElementsBySelector('div.controls a'); controls.invoke('observe', 'click', this.events.click); }, click: function(event) { this.stop(); var element = Event.findElement(event, 'a'); if (this.scrolling) this.scrolling.cancel(); this.moveTo(element.href.split("#")[1], this.scroller, { duration:this.options.duration }); Event.stop(event); }, moveTo: function(element, container, options){ this.current = $(element); Position.prepare(); var containerOffset = Position.cumulativeOffset(container), elementOffset = Position.cumulativeOffset($(element)); this.scrolling = new Effect.SmoothScroll(container, {duration:options.duration, x:(elementOffset[0]-containerOffset[0]), y:(elementOffset[1]-containerOffset[1])}); return false; }, next: function(){ if (this.current) { var currentIndex = this.current._index; var nextIndex = (this.sections.length - 1 == currentIndex) ? 0 : currentIndex + 1; } else var nextIndex = 1; this.moveTo(this.sections[nextIndex], this.scroller, { duration: this.options.duration }); }, previous: function(){ if (this.current) { var currentIndex = this.current._index; var prevIndex = (currentIndex == 0) ? this.sections.length - 1 : currentIndex - 1; } else var prevIndex = this.sections.length - 1; this.moveTo(this.sections[prevIndex], this.scroller, { duration: this.options.duration }); }, stop: function() { clearTimeout(this.timer); }, start: function() { this.periodicallyUpdate(); }, periodicallyUpdate: function() { if (this.timer != null) { clearTimeout(this.timer); this.next(); } this.timer = setTimeout(this.periodicallyUpdate.bind(this), this.options.frequency*1000); } }); Effect.SmoothScroll = Class.create(); Object.extend(Object.extend(Effect.SmoothScroll.prototype, Effect.Base.prototype), { initialize: function(element) { this.element = $(element); var options = Object.extend({ x: 0, y: 0, mode: 'absolute' } , arguments[1] || {} ); this.start(options); }, setup: function() { if (this.options.continuous && !this.element._ext ) { this.element.cleanWhitespace(); this.element._ext=true; this.element.appendChild(this.element.firstChild); } this.originalLeft=this.element.scrollLeft; this.originalTop=this.element.scrollTop; if(this.options.mode == 'absolute') { this.options.x -= this.originalLeft; this.options.y -= this.originalTop; } }, update: function(position) { this.element.scrollLeft = this.options.x * position + this.originalLeft; this.element.scrollTop = this.options.y * position + this.originalTop; } }); The HTML where inserted onto the page Code: <script type="text/javascript" charset="utf-8">var my_glider = new Glider('my-glider', {duration:0.5});</script> Looks to me like this ought to work, but since I'm here obviously it doesn't. Regarding the HTML in question, there are divs and they do contain child elements. I'm trying to write this in as generic a fashion as possible, without using IDs or other means of targeting elements. And yes, the jQuery library is referenced/linked to the page. Any pointers much appreciated. Thank you <script type="text/javascript"> // <![CDATA[ var x=0; var h=1000; var Divs=document.getElementsByTagName("div"); function fades() { var i=0; var s=0; $("div").fadeOut(1000); while(x<Divs.length) { setInterval('fadeIns()',h); } } function fadeIns() { if(i<100) { Divs[x].childNodes[s].style.opacity=i/100; i++; } else if(s<Divs[x].childNodes.length) { clearInterval(h); s++; i =0; setInterval('fadeIns()',h); } else { clearInterval(h); x++; fades(); } } window.onload=fades; // ]]> </script> Hello, I am trying to have 4 different images change when the user hits the start button. The speed they change in is based on what selection they have chosen (fast = every second, med = 3 sec, slow = 5 sec), and this cycle repeats until the user has hit the stop button. However, I am struggling to get this to work and have looked around the web for help, but cannot find it. <html> <head> <title>Untitled</title> </head> <body> <img src = "pic1.jpg" id = "swapper"> <form name = "form1"> <input type = "button" value = "Start" onclick = "Swap()"> <input type = "button" value = "Stop" onclick + "Stop()"> Speed: <select name = "Speed"> <option>Slow</option> <option>Medium</option> <option>Fast</option> </select> </form> <script language="JavaScript" type="text/javascript"> var Images = array["pic1.jpg","pic2.jpg","pic3.jpg","pic4.jpg"]; function Swap(){ } function Stop(){ } //clear it: clearInterval(imageSwapInterval); </script> </body> </html> I have not included any attempt of a code for the functions because I have tried at least 8 different things and have failed to get it to properly work each time. Also the array I set up does not work either. Thank you for the help and your time, Crimmm Can someone tell me why this short script won't work? <script type="text/JavaScript"> <!-- function timedRefresh(timeoutPeriod) { var number = rand(7); if (number == 1) { var bgcss = "theme1.css"; } else if (number == 2) { var bgcss = "theme2.css"; } else if (number == 3) { var bgcss = "theme3.css"; } else if (number == 4) { var bgcss = "theme4.css"; } else if (number == 5) { var bgcss = "theme5.css"; } else if (number == 6) { var bgcss = "theme6.css"; } else if (number == 7) { var bgcss = "theme7.css"; } document.write('<link href="bgcss "'+ 'type=text/css rel=stylesheet>'); } // --> </script> </head> <body onload="JavaScript:timedRefresh(10000);"> |