<?xml version="1.0" encoding="UTF-8"?><rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
> <channel><title>Comments on: How do I create a JavaScript that displays random image with the same ImageMap coordinates?</title> <atom:link href="http://www.findistore.com/how-do-i-create-a-javascript-that-displays-random-image-with-the-same-imagemap-coordinates/feed" rel="self" type="application/rss+xml" /><link>http://www.findistore.com/how-do-i-create-a-javascript-that-displays-random-image-with-the-same-imagemap-coordinates</link> <description>We are Professional Web Designer. We specialize in Website Design &#38; eCommerce Web Services</description> <lastBuildDate>Wed, 12 Oct 2011 00:03:14 +0000</lastBuildDate> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.1</generator> <xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" /> <item><title>By: richarduie</title><link>http://www.findistore.com/how-do-i-create-a-javascript-that-displays-random-image-with-the-same-imagemap-coordinates/comment-page-1#comment-4388</link> <dc:creator>richarduie</dc:creator> <pubDate>Mon, 06 Jul 2009 12:03:10 +0000</pubDate> <guid
isPermaLink="false">http://www.findistore.com/how-do-i-create-a-javascript-that-displays-random-image-with-the-same-imagemap-coordinates#comment-4388</guid> <description>The only constraint is that all of the images must be at least as large as the coordinate definitions of your map areas.
~~~~~~~~~~~~
&lt;html&gt;
&lt;head&gt;
&lt;script&gt;
// create array of string to hold names of image files
var imgSrcs = [
&#039;img0.gif&#039;, &#039;img1.gif&#039;, &#039;img2.gif&#039;
]
// assign a randomly selected source attribute to the map
function setImgSrc() {
// how many images available for random selection
var last = imgSrcs.length;
// get a random real value on the scale [0, last]
var imgIdx = Math.random() * last;
// convert real to integer by truncation - ensure index
// value stays in array index range, in case random()*last
// produced last, i.e., random() generated 1
var imgIdx = Math.min( last - 1, Math.floor( imgIdx ) );
document.getElementById( &#039;mapImg&#039; ).src = imgSrcs[ imgIdx ];
}
window.onload = setImgSrc;
&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;img id=&quot;mapImg&quot; src=&quot;&quot; width=&quot;200&quot; height=&quot;200&quot; alt=&quot;&quot; usemap=&quot;#yourMap&quot; /&gt;
&lt;map name=&quot;yourMap&quot;&gt;
&lt;!-- whatever your map&#039;s area definitions are go here --&gt;
&lt;area shape=&quot;rect&quot; coords=&quot;0,0,100,100&quot; href=&quot;first.html&quot; alt=&quot;&quot; /&gt;
&lt;area shape=&quot;rect&quot; coords=&quot;0,100,0,100&quot; href=&quot;second.html&quot; alt=&quot;&quot; /&gt;
&lt;/map&gt;
&lt;/body&gt;
&lt;/html&gt;</description> <content:encoded><![CDATA[<p>The only constraint is that all of the images must be at least as large as the coordinate definitions of your map areas.<br
/> ~~~~~~~~~~~~<br
/> &lt;html&gt;<br
/> &lt;head&gt;<br
/> &lt;script&gt;<br
/> // create array of string to hold names of image files<br
/> var imgSrcs = [<br
/> 'img0.gif', 'img1.gif', 'img2.gif'<br
/> ]</p><p> // assign a randomly selected source attribute to the map<br
/> function setImgSrc() {<br
/> // how many images available for random selection<br
/> var last = imgSrcs.length;<br
/> // get a random real value on the scale [0, last]<br
/> var imgIdx = Math.random() * last;<br
/> // convert real to integer by truncation &#8211; ensure index<br
/> // value stays in array index range, in case random()*last<br
/> // produced last, i.e., random() generated 1<br
/> var imgIdx = Math.min( last &#8211; 1, Math.floor( imgIdx ) );<br
/> document.getElementById( &#8216;mapImg&#8217; ).src = imgSrcs[ imgIdx ];<br
/> }</p><p> window.onload = setImgSrc;<br
/> &lt;/script&gt;<br
/> &lt;/head&gt;<br
/> &lt;body&gt;<br
/> &lt;img id=&quot;mapImg&quot; src=&quot;&quot; width=&quot;200&quot; height=&quot;200&quot; alt=&quot;&quot; usemap=&quot;#yourMap&quot; /&gt;<br
/> &lt;map name=&quot;yourMap&quot;&gt;<br
/> &lt;!&#8211; whatever your map&#8217;s area definitions are go here &#8211;&gt;<br
/> &lt;area shape=&quot;rect&quot; coords=&quot;0,0,100,100&quot; href=&quot;first.html&quot; alt=&quot;&quot; /&gt;<br
/> &lt;area shape=&quot;rect&quot; coords=&quot;0,100,0,100&quot; href=&quot;second.html&quot; alt=&quot;&quot; /&gt;<br
/> &lt;/map&gt;<br
/> &lt;/body&gt;<br
/> &lt;/html&gt;</p> ]]></content:encoded> </item> </channel> </rss>
