| | Hi! I want a random image, do i need to set that up with your web host? Can i implement coad into my images? Thanks! |
|
|
Source: http://javascript.internet.com/miscellaneo...ndom-image.html CODE <!-- TWO STEPS TO INSTALL RANDOM IMAGE: 1. Copy the coding into the HEAD of your HTML document 2. Add the last code into the BODY of your HTML document --> <!-- STEP ONE: Paste this code into the HEAD of your HTML document --> <HEAD> <script LANGUAGE="JavaScript"> <!-- This script and many more are available free online at --> <!-- The JavaScript Source!! http://javascript.internet.com --> <!-- Begin // Set up the image files to be used. var theImages = new Array() // do not change this // To add more image files, continue with the // pattern below, adding to the array. theImages[0] = '1.gif' theImages[1] = '2.gif' theImages[2] = '3.gif' theImages[3] = '4.gif' // do not edit anything below this line var j = 0 var p = theImages.length; var preBuffer = new Array() for (i = 0; i < p; i++){ preBuffer[i] = new Image() preBuffer[i].src = theImages[i] } var whichImage = Math.round(Math.random()*(p-1)); function showImage(){ document.write('<img src="'+theImages[whichImage]+'">'); } // End --> </script> </HEAD> <!-- STEP TWO: Copy this code into the BODY of your HTML document --> <BODY> <script LANGUAGE="JavaScript"> <!-- This script and many more are available free online at --> <!-- The JavaScript Source!! http://javascript.internet.com --> <!-- Begin showImage(); // End --> </script> <p><center> <font face="arial, helvetica" size"-2">Free JavaScripts provided<br> by <a href="http://javascriptsource.com">The JavaScript Source</a></font> </center><p> <!-- Script Size: 1.49 KB --> Well sorry if I was suppose to use quote tags instead of code. It requires javascript, and you don't need to set it up with your web host. Every time you refresh the page, it will show a different image.
Here's an even smaller random image script but it requires php instead. Trap17 has php so all your visitors will be able to use this.
For this script each image needs to be called something1.png, something2.png, something3.png etc. You can change the text "something" and the image extension into something you choose but the number must remain in place. It is assumed that all your images are stored in the directory images/ but you can change that in the script. All your images must be stored in the same directory and all image extensions must be the same. CODE <? // Selects a random number from 1 to 4. Change 4 to the amount of images you have $randomNumber = rand(1,4); // Displays the image echo "<img src=\"images/something" . $randomNumber . ".png\" alt=\"My random image\">"; ?> And that's it
No, sorry should have clarified myself... i dont mean on the html page, i mean on the image itself... like a dynamic image...
HOw do i add lines of coad to the acctual image itself... thanks!
Adding codes on the image itself is impossible. Unless your a hacker and is attacking a security hole on images(It does exists). PHP can create dynamic pictures and trap17 has GD enable,hasn't it? Describe what you want and we can tell you other method of doing what you want!
Ok,
like how do they make those couters? Its one image like counter.jpg, but every time you refresh the image it automatically counts... is that php generating an image? and if so, why isn't it a php page i link to, instead of a jpg? Example here ------- Another thing how do they make those random message board sig things, like i have one in my sig... its different every time, but its just a regular <img> tag... is that PHP generating the image? and if so, why isn't it a php page i link to, instead of a jpg? -- Thanks!
Maybe it's a virtual directory and the jpg extension is generated by PHP. But the virtual directory ends with a .php doesn't it?
They maybe make php recognises the jpg extension and php will process every jpg file there!
hmm not sure, but just look at the image in my sig... how does danasoft do it?
its random, but it has a .jpg extention!
I think Danasoft did it with php virtual directory and apache's mod-rewrite (I've just done the research on this and I'm not guranteeing it's right).
The folder sig is a "real" directory but nothing exists in there except 2 files, "index.php" and ".htaccess". The content htaccess tells apache to forward all the files with a ".jpg" extension to the php file which process the files.
Similar Topics
Keywords : random, images, make, random, image
Random intervals (5) Ive had this problem for 2 years now, i surf the net websites, online games , you know the usuall help with image maps... (4) Ok, I set up an image map for the sidebar on my site, www.rlclan.trap17.com . what i was wondering Looking for random, images, make, random, image
|
|
![]() Random Images - how to make a random image? |
| ADD REPLY / Got an Opinion! | a humble request :-) | RAPID SEARCH! | Free Hosting | [X] |
|
Express your Opinions, Thoughts or Contribute more info. to help others. Ask your Doubts & Queries to get answers, So that "Together We can help others!" |
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP. | 500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE |
|