rotating image - Each time a page is accessed, the images changes
Try this URL, it is a random image script:
http://www.wsabstract.com/script/cut118.shtml
Hope this helps.
----------
John Pollock
http://www.pageresource.com
Try this URL, it is a random image script:
http://www.wsabstract.com/script/cut118.shtml
Hope this helps.
----------
John Pollock
http://www.pageresource.com
shpek posted this at 18:52 — 21st June 1999.
They have: 66 posts
Joined: Apr 1999
Hi John,
Thanks 4 the quick reply! This is the code I think you were refering to:
<SCRIPT LANGUAGE="JavaScript">
<!--
function write_img_src(IMG_SRC)
{
random = Math.random() * 10000000000;
document.write("<IMG SRC=\"" + IMG_SRC + random + "\" BORDER=\"1\" width=468 height=60 alt=\"Click here!\">");
}
//-->
</SCRIPT>
<!-- Include the following every place you want an ad to appear -->
<!-- Only add the "&SC=Y" to the first banner -->
------------------------
Could you provide me a bit more detail of this line:
document.write("<IMG SRC=\"" + IMG_SRC + random + "\" BORDER=\"1\" width=468 height=60 alt=\"Click here!\">");
Just not sure what the entire statement means...
Thanks again!
Shpek
John Pollock posted this at 21:08 — 21st June 1999.
He has: 628 posts
Joined: Mar 1999
That is the line that writes the random image on the page. All the back slashes are there to escape the quote marks so that there are no strings cut off too soon.
It is in effect printing HTML along these lines:
<IMG SRC="something.gif" BORDER="1" width=468 height=60 alt="Click here!">
I'm not exactly sure on this, the random variable creates a random number, so it displays a random image.
----------
John Pollock
http://www.pageresource.com
Java Script: A Beginner's Guide
Page Resource
Anonymous posted this at 01:12 — 22nd June 1999.
They have: 5,633 posts
Joined: Jan 1970
There are two things to note:
1.function write_img_src(IMG_SRC)
2.SRC=\"" + IMG_SRC + random
The actual image file is built from these two. The prefix (eg "banner") part is controlled by the function call argument "IMG_SRC". You can change the image prefix to suit your own needs, eg, a prefix for link exchanged and another for paid ad.
The 2nd part: Math.random() is a JavaScript function generating a random number between 0 and 1. Therefore, the 10 billion is just a multiplier. Change this to suit your need. Eg, you have 100 images, then the multipier to use is 100. Note that you may need to round off the number to interger, such as using Math.round() or Math.floor().
In summary, you need to do a little editing on the script in order to use it for your site.
----------
-------------------------------
http://www.epls.com - free groupware online
shpek posted this at 03:43 — 22nd June 1999.
They have: 66 posts
Joined: Apr 1999
Can anyone tell me where to I can find a javascript that swaps an image on a page evertime that page is accessed? I'd like the images to populate randomly...no sequencing.
I thought this would be a simple script to find but I'm having trouble locating it.
Thanks
Much
Shpek
shpek posted this at 04:14 — 22nd June 1999.
They have: 66 posts
Joined: Apr 1999
I think I agree using the CGI script.
Pat, the one you suggested looks great. I think I'm going to try that one out. I'll let you know the results.
Thanks once again to all of your suggestions!!
Shpek
shpek posted this at 04:45 — 22nd June 1999.
They have: 66 posts
Joined: Apr 1999
One last thing...
Must the html file be renamed to .Shtml?
And I'm not 100% sure what to include in the html/shtml that will load this script.
Worldmart's page has the following:
<a href="http://worldwidemart.com/scripts/ads/redirect.cgi?isk+iskD.gif+http://software.infoseek.com/products/ultraseek/ultratop20.htm"><img src="http://worldwidemart.com/scripts/ads/images/isk/iskD.gif" height=60 width=468 alt="Ultraseek. Click now for a FREE download." border=1></a>
Thanks
Shpek
John Pollock posted this at 04:49 — 22nd June 1999.
He has: 628 posts
Joined: Mar 1999
Whether you need to rename the html file or not depends on your web host, ask them if you need to. You might also ask the which form of the SSI tag to use, but I thing most support the exec cgi command, something like this:
<!--#exec cgi="scriptname.cgi"-->
And yes, the cgi script is better because it will work with all browsers that render images.
----------
John Pollock
http://www.pageresource.com
Java Script: A Beginner's Guide
Page Resource
shpek posted this at 17:27 — 22nd June 1999.
They have: 66 posts
Joined: Apr 1999
Hey John,
Is <!--#exec cgi="scriptname.cgi"--> exactly how it would look in the code?
I've only used cgi scripts in forms so this is new to me.
Could you give me another example of how I would be writing this in html?
I have an imagess folder onthe sever so the path, from the images folder would be: ../cgi-bin/script.pl5
Thanks Again!
shpek posted this at 19:31 — 22nd June 1999.
They have: 66 posts
Joined: Apr 1999
Ok....
I got the script to work
BUT... after each image I am getting the following message:
Content-Type: text/html
ERROR!
/afs/.aa.psiweb.com/home/4/aa002028/fliweb/cgi-bin/rand_image.pl5 did not return a true value at
/opt/scripts/cgi-bin/Public/safeperl5 line 80.
Do any of you know what this means and how I can correct it?
Shpke
JP Stones posted this at 22:49 — 22nd June 1999.
They have: 2,390 posts
Joined: Nov 1998
I can't help but feel that a simple CGI script would eclipse this problem.
JP
----------
The Webmaster Promotion and Resource Center.
http://www.what-next.com
Anonymous posted this at 03:22 — 23rd June 1999.
They have: 5,633 posts
Joined: Jan 1970
as JP said, if you are allowed to use server-side-includes on your sites, a cgi-script will help. i often use SSI Random Image Displayer:http://worldwidemart.com/scripts/ssi_image.shtml to do this but there are probably hundreds of scripts like this on the net, and in case you don't like SSI Random just choose the one that fits best to your wishes....
cu
patrick
----------
http://www.allcgi.de
not quite up yet, but see if you can find something for you!
shpek posted this at 04:44 — 23rd June 1999.
They have: 66 posts
Joined: Apr 1999
Success!
The CGI script works great!!
*NOTE*
Pat, the script you recommended is a good one but anyone who decides to use it must put a "1" at the very bottom of the script. Otherwise you will get an ERROR message. This will save u time and frustration.
THANKS ALL!!
)
Shpek
shpek posted this at 04:45 — 23rd June 1999.
They have: 66 posts
Joined: Apr 1999
Damn faces...
Meant to say
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.