Quantcast

Jump to content

» «
Photo

Random Images With Image Mapping?

2 replies to this topic
Nez Man
  • Nez Man

    Naean Howlett-Foster

  • Members
  • Joined: 09 Jun 2008
  • None

#1

Posted 18 May 2014 - 04:57 PM Edited by Nez Man, 18 May 2014 - 04:58 PM.

Alright, so after several attempts and ultimately failing at trying to figure out what must surely be a rather simple coding task, I was wondering if any fine folk here would be so kind to help me in the endeavour of inserting a random image code on my website which would change the displayed image upon page reload, but at the same time would also incorporate each aforementioned image with image link mapping.

 

Any and all assistance with this would be much appreciated and is somewhat although not pressingly urgent, as I have been meaning to beef up the aesthetics and functionality of my website for quite a prolonged time, with this being a key part of it. Many thanks in advance.  :)

 

As a side note, a search online did not produce any results for pre-existing and tutorial-inclusive coding for both randomisation and mapping purposes. I did try, but no cigar.  ^o^


trip
  • trip

    ~

  • Andolini Mafia Family
  • Joined: 10 Oct 2007
  • United-States

#2

Posted 18 May 2014 - 06:04 PM

What are you coding in?

 

Here is some javascript that might help if you are just using old fashioned HTML:

<script type="text/javascript">
var total_images = 3;

var random_number = Math.floor((Math.random()*total_images));

var random_img = new Array();

random_img[0] = '<a href="page1.html"><img src="images/image1.gif"></a>';

random_img[1] = '<a href="page2.html"><img src="images/image2.gif"></a>';

random_img[2] = '<a href="page3.html"><img src="images/image3.gif"></a>';

document.write(random_img[random_number]);
</script>

Nez Man
  • Nez Man

    Naean Howlett-Foster

  • Members
  • Joined: 09 Jun 2008
  • None

#3

Posted 18 May 2014 - 06:48 PM Edited by Nez Man, 18 May 2014 - 09:13 PM.

 

What are you coding in?

 

Here is some javascript that might help if you are just using old fashioned HTML:

<script type="text/javascript">
var total_images = 3;

var random_number = Math.floor((Math.random()*total_images));

var random_img = new Array();

random_img[0] = '<a href="page1.html"><img src="images/image1.gif"></a>';

random_img[1] = '<a href="page2.html"><img src="images/image2.gif"></a>';

random_img[2] = '<a href="page3.html"><img src="images/image3.gif"></a>';

document.write(random_img[random_number]);
</script>

 

I am using a W.Y.S.I.W.Y.G. editor on Webs, however it fully supports insertion of custom HTML code.

 

I have used that kind of code before for image randomisation, thanks! However, I am looking to insert code which would be able to have image randomisation across four images which all also have image mapping (Links in certain areas of the image.) as well. The code you provided is only the randomisation section.  ;)





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users