Current location: Hot Scripts Forums » General Web Coding » JavaScript » Rotate Images OnLoad


Rotate Images OnLoad

Reply
  #1 (permalink)  
Old 01-07-07, 10:38 PM
kgcr@juno.com kgcr@juno.com is offline
New Member
 
Join Date: Jan 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Rotate Images OnLoad

I want to rotate images onLoad but I don't want them to rotate at random. I want the next image to load each time rather then to have the images load at random. My goal is to have people see different images each time they come to our web site. I've noticed that, with the random loading, some images seem to come up often while others are seldom seen. I've found numerous scripts that load images at random but none that load them in order. Is there a way to do this?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 01-09-07, 04:39 AM
Wolf1994 Wolf1994 is offline
Wannabe Coder
 
Join Date: Sep 2005
Location: Russia
Posts: 117
Thanks: 0
Thanked 0 Times in 0 Posts
You need server side scripting for your goal.

PHP Code:

$max=10;//quantity of images


$fp=fopen ("img.txt""r");
$n=fread ($fp)+1;
if (
$n>$max)
 
$n=1;
fclose ($fp);

$fp=fopen ("img.txt""w");
fwrite ($fp$n);
fclose ($fp);

print 
'<img src="pic'.$n.'.gif" />'
This script will show images from "pic1.gif" till "pic10.gif", by round.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 04-08-09, 02:26 PM
nick007 nick007 is offline
New Member
 
Join Date: Apr 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Question

It is been a while on this thread but I am looking for the same functionality , the php code did not work ,
$max=10;//quantity of images

$fp=fopen ("img.txt", "r");
$n=fread ($fp)+1;
if ($n>$max)
$n=1;
fclose ($fp);

$fp=fopen ("img.txt", "w");
fwrite ($fp, $n);
fclose ($fp);

print '<img src="pic'.$n.'.gif" />';

what does img.txt contain , I am getting the following error "Warning: Wrong parameter count for fread() "
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 04-08-09, 03:10 PM
Wolf1994 Wolf1994 is offline
Wannabe Coder
 
Join Date: Sep 2005
Location: Russia
Posts: 117
Thanks: 0
Thanked 0 Times in 0 Posts
Sorry for mistake. Use:
PHP Code:

$n=fread ($fpfilesize ("img.txt"))+1
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #5 (permalink)  
Old 04-10-09, 05:57 PM
nick007 nick007 is offline
New Member
 
Join Date: Apr 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Thank You

Hi thank you for this script, it worked on my test server that has php 5.2 installed but did not work on the server that I needed to, the php installed PHP Version 4.4.1 allow_call_time_pass_reference is set to Off Off. The script only displays one image which is the first image in sequence. Any suggestion for how to resolve?

Thanks
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #6 (permalink)  
Old 04-11-09, 05:48 AM
dgreenhouse's Avatar
dgreenhouse dgreenhouse is offline
Aspiring Coder
 
Join Date: Mar 2009
Location: San Francisco
Posts: 457
Thanks: 0
Thanked 3 Times in 3 Posts
Actually, you'll need one of the following:
1- A client side script if JavaScript is enabled
2- If JavaScript isn't enabled, a gif or png with multiple images embedded
3- If JavaScript isn't enabled, an iFrame which refreshes at some pre-determined interval
4- Any of the above in combination
5- All except number#2, involves some type of server-side processing in addition.

If this spec: "I want the next image to load each time rather then to have the images load at random. My goal is to have people see different images each time they come to our web site.", is as restrictive as it seems to be, you'll need to explore a more involved solution.

It sounds like you want:
Any user to experience a different image when they visit your site?
All users to experience a different image when they visit your site?

???

Last edited by dgreenhouse; 04-11-09 at 05:52 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Assigning images according to page type(s) deltatango5 PHP 2 12-15-06 08:39 AM
Royalty free cartoon images: Please reply mcrob The Lounge 2 10-04-05 10:40 AM
Rotating Text Links & Images daily... J-Deak Script Requests 5 02-13-05 06:06 PM
image's onload event behaves strangely davidklonski JavaScript 0 07-07-04 12:20 PM
List images and zip before download jaimexyz Script Requests 0 09-01-03 04:01 PM


All times are GMT -5. The time now is 01:12 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.