Go Back  HTML Forums - Free Webmaster Forums and Help Forums > WEBSITE DEVELOPMENT > Client Side Scripting
User Name:
Password:
 

Reply
Thread Tools   Display Modes
  View First Unread
 
Old 08-16-2007, 12:55 PM
  #1
Greenback
Battler (Level 3)
 
Join Date: Aug 2007
Location: Nottingham, ENG
Posts: 23
iTrader: (0)
Greenback is an unknown quantity at this point
Image rotation on page load rather than timed

hi,

i have an image rotation code, but its working on switching the code on a timer, and i want it to appear randomly on the page load. anybody know how to change the code? i have the timer part of it below.

thanks in advance.

var interval = 1.5; // delay between rotating images (in seconds)
var random_display = 1; // 0 = sequential, 1 = random
interval *= 1000;
Greenback is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 08-16-2007, 10:06 PM
  #2
BonRouge
Winemaster
 
BonRouge's Avatar
 
Join Date: Aug 2005
Location: Sendai, Japan
Posts: 3,083
iTrader: (0)
BonRouge has a spectacular aura aboutBonRouge has a spectacular aura about
This might help... http://bonrouge.com/~faq#rotate (maybe)
BonRouge is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 08-17-2007, 05:58 AM
  #3
Greenback
Battler (Level 3)
 
Join Date: Aug 2007
Location: Nottingham, ENG
Posts: 23
iTrader: (0)
Greenback is an unknown quantity at this point
i looked there before i posted but it didnt help. got some other usefull stuff from there though thanks. its all in one html document, so it doesnt link it to any external phps or anything, i just want it random on the page load rather than using a timer, but i cant find the code, and i dont know where to put it.

cheers.
Greenback is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 08-17-2007, 06:10 AM
  #4
BonRouge
Winemaster
 
BonRouge's Avatar
 
Join Date: Aug 2005
Location: Sendai, Japan
Posts: 3,083
iTrader: (0)
BonRouge has a spectacular aura aboutBonRouge has a spectacular aura about
Did you see this one? http://bonrouge.com/~rand-img-js
BonRouge is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 08-17-2007, 07:38 AM
  #5
Greenback
Battler (Level 3)
 
Join Date: Aug 2007
Location: Nottingham, ENG
Posts: 23
iTrader: (0)
Greenback is an unknown quantity at this point
hadnt seen that one. cheers. i still cant get it to work though, but obviously does, cause it works on the site. im just not sure where it needs to go, and how to fit it in with my current code. if you have any suggestions.

cheers.
Greenback is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 08-17-2007, 07:14 PM
  #6
BonRouge
Winemaster
 
BonRouge's Avatar
 
Join Date: Aug 2005
Location: Sendai, Japan
Posts: 3,083
iTrader: (0)
BonRouge has a spectacular aura aboutBonRouge has a spectacular aura about
Code:
function randImg() {
var links= new Array(3);
links[0]='wine.jpg'; 
links[1]='whisky.jpg';
links[2]='beer.jpg';
var ran_unrounded=Math.random()*2;
var rand=Math.round(ran_unrounded);
var image= links[rand];
var imagehtml='<img src="'+image+'" alt="'+image.replace(/.jpg/, "")+'" />';
p = document.getElementById('rand-img');
if (p) {
 range = document.createRange();
 range.setStartBefore(p);
 p.appendChild(range.createContextualFragment(imagehtml));
 }
}

window.onload=randImg;
Lines 3,4,5 have the names of your images.
The image appears in a paragraph (though it could be a div) with the id 'rand-img' (see line 10).
BonRouge is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 08-20-2007, 04:01 PM
  #7
Greenback
Battler (Level 3)
 
Join Date: Aug 2007
Location: Nottingham, ENG
Posts: 23
iTrader: (0)
Greenback is an unknown quantity at this point
cheers. have it working now.
Greenback is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 08-25-2007, 08:23 AM
  #8
muneepenee
Catapulted
 
Join Date: Aug 2007
Posts: 65
iTrader: (0)
muneepenee is an unknown quantity at this point
1. yu kan kall NE funkshun inside the javascript kode & it will run 1 time on lode
function wotever(){......}
wotever();
2. zampel: tu find out how long it take tu lode...
At top av paej, put js kode tu get the time.
at bottom repeet same kode.
lode time=differens tween 2 times.

Comments on this post
MikeTacular agrees: Why the crap do you write like that?

Last edited by muneepenee : 08-25-2007 at 08:27 AM.
muneepenee is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 08-25-2007, 11:28 AM
  #9
BonRouge
Winemaster
 
BonRouge's Avatar
 
Join Date: Aug 2005
Location: Sendai, Japan
Posts: 3,083
iTrader: (0)
BonRouge has a spectacular aura aboutBonRouge has a spectacular aura about
muneepenee,

Do us all a favour and write in English. There are many users of this site whose first language is not English. Your garbled version of it will only confuse them.

Thanks.
BonRouge is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote

Reply
KEEP TABS
SPONSORS
 
Boxedart



 
 


 
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
  
 
 
 



 
  POSTING RULES
 
 
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Thread Tools
Display Modes

Forum Jump

 

All times are GMT -5. The time now is 07:41 PM.

   

Mascot team created by Drawshop.com

Powered by vBulletin® Version 3.6.7
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.

Server Monitoring by ENIACmonitor 0.01
HTMLforums.com © Big Resources, Inc. Web Design by BoxedArt.com
vRewrite 1.5 beta SEOed URLs completed by Tech Help Forum and Chalo Na.