Computer Hope

Internet & Networking => Web design => Topic started by: steven32collins on April 21, 2010, 02:14:53 AM

Title: random image
Post by: steven32collins on April 21, 2010, 02:14:53 AM
how can you make it so every time a page loads a random image is displayed out of an array of 2 - 3 but it cannot have a script (unless if you can make it work on signatures on a forum)
Title: Re: random image
Post by: steven32collins on April 21, 2010, 02:25:22 AM
also this is the script ive got so far and when its inserted onto the webpage its modifyed

before added to the page

<script type="text/javascript">
      //Javascript Created by Computerhope
      //store the quotations in arrays
      images = new Array(4);
      images[0] = "<img src='http://www.computerhope.com/banners/banner.gif' />";
      images[1] = "<a href = 'http://www.computerhope.com/history/index.htm'><img src='http://www.computerhope.com/banners/banner2.gif' alt='Computer History'>[/url]";
      images[2] = "<a href = 'http://www.computerhope.com/index.htm'><img src='http://www.computerhope.com/banners/banner3.gif' alt='Visit Computer Hope'>[/url]";
      images[3] = "<a href = 'http://www.computerhope.com/newslet.htm'><img src='http://www.computerhope.com/banners/banner4.gif' alt='Computer Hope Newsletter'>[/url]";
      index = Math.floor(Math.random() * images.length);
document.write(images[index]);
      //done
       </script>


after its added to the page

<div class='signature'> </div>
&#60;script type="text/javascript">
      //Javascript Created by Computerhope
      //store the quotations in arrays
      images = new Array(4);
      images[0] = "<img src='http://www.computerhope.com/banners/banner.gif' />";
      images[1] = "<a href = 'http://www.computerhope.com/history/index.htm'><img src='http://www.computerhope.com/banners/banner2.gif' alt='Computer History'>[/url]";
      images[2] = "<a href = 'http://www.computerhope.com/index.htm'><img src='http://www.computerhope.com/banners/banner3.gif' alt='Visit Computer Hope'>[/url]";
      images[3] = "<a href = 'http://www.computerhope.com/newslet.htm'><img src='http://www.computerhope.com/banners/banner4.gif' alt='Computer Hope Newsletter'>[/url]";
      index = Math.floor(Math.random() * images.length);
document.write(images[index]);
      //done
       </script>
<div> </div>
Title: Re: random image
Post by: kpac on April 21, 2010, 10:09:45 AM
I don't really understand what you're trying to do.
Title: Re: random image
Post by: steven32collins on April 23, 2010, 02:19:46 AM
right i have a couple of signatures i would like a random one to appear each time the page loads

now ive looked on the website it gave me the first script on my last post but when its inserted onto the forum the < on the script changes to &#60; so then the script wont work please help :)
Title: Re: random image
Post by: BC_Programmer on April 23, 2010, 02:28:11 AM
right i have a couple of signatures i would like a random one to appear each time the page loads

now ive looked on the website it gave me the first script on my last post but when its inserted onto the forum the < on the script changes to &#60; so then the script wont work please help :)

you cannot use scripts on the forum.
Title: Re: random image
Post by: kpac on April 23, 2010, 10:04:28 AM
you cannot use scripts on the forum.
...obviously.
Title: Re: random image
Post by: steven32collins on April 23, 2010, 01:44:53 PM
well im kinda the guy who built the forum :)

how can i make it accseptible or work?
Title: Re: random image
Post by: kpac on April 23, 2010, 04:02:28 PM
What forum are you talking about?
Title: Re: random image
Post by: steven32collins on April 24, 2010, 12:00:23 AM
its made by invision power board


it uses ibf code aswell as html
Title: Re: random image
Post by: kpac on April 24, 2010, 02:50:58 AM
Well, let me tell you it's not a good idea.
Title: Re: random image
Post by: steven32collins on April 24, 2010, 10:29:35 AM
why?
Title: Re: random image
Post by: kpac on April 24, 2010, 12:50:35 PM
Security. That's the whole idea behind removing the <script> tag from your signature. Anyone or anything could easily get into something they're not supposed to.
Title: Re: random image
Post by: steven32collins on April 24, 2010, 03:35:54 PM
ok so how can i do it without the script tag?
Title: Re: random image
Post by: steven32collins on April 24, 2010, 03:37:24 PM
what about php?
Title: Re: random image
Post by: kpac on April 24, 2010, 03:47:20 PM
ok so how can i do it without the script tag?
HTML or CSS along cannot display a random image. PHP isn't allowed either.
Title: Re: random image
Post by: steven32collins on April 25, 2010, 03:41:19 AM
ok what about the onmouseover atrabute for img tag
Title: Re: random image
Post by: kpac on April 25, 2010, 04:11:35 AM
That's a script.

What you can do, though, is make an animated GIF image, like the userbars you'd see in some member's signatures.
Title: Re: random image
Post by: steven32collins on April 25, 2010, 07:54:26 AM
ok thanks :)

what free program should i use?