<?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: Random Header Image With Javascript</title> <atom:link href="http://www.elanman.co.uk/2008/09/random-header-image-with-javascript/feed/" rel="self" type="application/rss+xml" /><link>http://www.elanman.co.uk/2008/09/random-header-image-with-javascript/</link> <description>ElanMan&#039;s Code Snippets</description> <lastBuildDate>Wed, 18 Jan 2012 12:55:26 +0000</lastBuildDate> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.1</generator> <item><title>By: andrytosh</title><link>http://www.elanman.co.uk/2008/09/random-header-image-with-javascript/comment-page-1/#comment-350</link> <dc:creator>andrytosh</dc:creator> <pubDate>Wed, 19 Oct 2011 20:41:28 +0000</pubDate> <guid
isPermaLink="false">http://www.elanman.co.uk/?p=142#comment-350</guid> <description>excelent...</description> <content:encoded><![CDATA[<p>excelent&#8230;</p> ]]></content:encoded> </item> <item><title>By: Mars</title><link>http://www.elanman.co.uk/2008/09/random-header-image-with-javascript/comment-page-1/#comment-153</link> <dc:creator>Mars</dc:creator> <pubDate>Sat, 14 Nov 2009 10:07:16 +0000</pubDate> <guid
isPermaLink="false">http://www.elanman.co.uk/?p=142#comment-153</guid> <description>Hi. Anyone know how to change the site header when switching styles. I&#039;m using a style switcher from &lt;a href=&quot;http://www.dynamicdrive.com/dynamicindex9/stylesheetswitcher.htm&quot; rel=&quot;nofollow&quot;&gt;dynamic drive&lt;/a&gt;.</description> <content:encoded><![CDATA[<p>Hi. Anyone know how to change the site header when switching styles. I&#8217;m using a style switcher from <a
href="http://www.dynamicdrive.com/dynamicindex9/stylesheetswitcher.htm" rel="nofollow">dynamic drive</a>.</p> ]]></content:encoded> </item> <item><title>By: thomas</title><link>http://www.elanman.co.uk/2008/09/random-header-image-with-javascript/comment-page-1/#comment-135</link> <dc:creator>thomas</dc:creator> <pubDate>Tue, 15 Sep 2009 19:17:38 +0000</pubDate> <guid
isPermaLink="false">http://www.elanman.co.uk/?p=142#comment-135</guid> <description>hi,
yes this is what im looking for but i tried it on mine but nothing appears what things do i change in the code so it can work on mine i tried changing the pics do i put something in where it says url towards the end of the code
i checked out the link &amp; its exactly what i want
anyways do i put my website in replacement of the one mentioned in the code?or do i not put one in there? like i said it seems to come up blank
ty hope i can find a code that actually works cause i know this one is exactly what im looking for
ty</description> <content:encoded><![CDATA[<p>hi,<br
/> yes this is what im looking for but i tried it on mine but nothing appears what things do i change in the code so it can work on mine i tried changing the pics do i put something in where it says url towards the end of the code<br
/> i checked out the link &amp; its exactly what i want<br
/> anyways do i put my website in replacement of the one mentioned in the code?or do i not put one in there? like i said it seems to come up blank<br
/> ty hope i can find a code that actually works cause i know this one is exactly what im looking for<br
/> ty</p> ]]></content:encoded> </item> <item><title>By: ElanMan</title><link>http://www.elanman.co.uk/2008/09/random-header-image-with-javascript/comment-page-1/#comment-15</link> <dc:creator>ElanMan</dc:creator> <pubDate>Wed, 04 Mar 2009 22:18:01 +0000</pubDate> <guid
isPermaLink="false">http://www.elanman.co.uk/?p=142#comment-15</guid> <description>Hi BlueCougar.
I&#039;ll make a new post which combines this one and the &lt;a href=&quot;http://www.elanman.co.uk/2009/03/simple-javascript-style-switcher/&quot; title=&quot;Simple Javascript Style Switcher&quot; rel=&quot;nofollow&quot;&gt;&#039;Simple Javascript Style Switcher&#039;&lt;/a&gt;.</description> <content:encoded><![CDATA[<p>Hi BlueCougar.<br
/> I&#8217;ll make a new post which combines this one and the <a
href="http://www.elanman.co.uk/2009/03/simple-javascript-style-switcher/" title="Simple Javascript Style Switcher" rel="nofollow">&#8216;Simple Javascript Style Switcher&#8217;</a>.</p> ]]></content:encoded> </item> <item><title>By: BlueCougar</title><link>http://www.elanman.co.uk/2008/09/random-header-image-with-javascript/comment-page-1/#comment-13</link> <dc:creator>BlueCougar</dc:creator> <pubDate>Sun, 01 Mar 2009 19:11:40 +0000</pubDate> <guid
isPermaLink="false">http://www.elanman.co.uk/?p=142#comment-13</guid> <description>So, how would this be done with a javascript style switcher?</description> <content:encoded><![CDATA[<p>So, how would this be done with a javascript style switcher?</p> ]]></content:encoded> </item> <item><title>By: ElanMan</title><link>http://www.elanman.co.uk/2008/09/random-header-image-with-javascript/comment-page-1/#comment-12</link> <dc:creator>ElanMan</dc:creator> <pubDate>Wed, 18 Feb 2009 17:05:46 +0000</pubDate> <guid
isPermaLink="false">http://www.elanman.co.uk/?p=142#comment-12</guid> <description>Hi Rob,
To have the image change after a period of time, you could wrap the above code in its own function then use setTimeout to call it.
Example
&lt;p class=&quot;code&quot;&gt;&lt;code&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
function RandImg() {
var header = document.getElementById(&#039;header&#039;);
var pictures = new Array(&#039;images/image1.jpg&#039;,&#039;images/image2.jpg&#039;,&#039;images/image3.jpg&#039;,&#039;images/image4.jpg&#039;,&#039;images/image5.jpg&#039;);
var numPics = pictures.length;
if (document.images) {
var chosenPic = Math.floor((Math.random() * numPics));
header.style.background = &#039;url(&#039; + pictures[chosenPic] + &#039;)&#039;;
}
setTimeout(RandImg,2000);
}
window.onload = RandImg;
&lt;/script&gt;
&lt;/code&gt;&lt;/p&gt;
I&#039;ve put an example here which changes the image every 2 seconds.
&lt;a href=&quot;http://www.elanman.co.uk/js_examples/random_image2.html&quot; rel=&quot;nofollow&quot;&gt;http://www.elanman.co.uk/js_examples/random_image2.html&lt;/a&gt;.
Notice that sometimes the image doesn&#039;t appear to change.
That&#039;s because the same image can be selected randomly the next time the function is called. Having more images in the array will lessen the chances of this happening.</description> <content:encoded><![CDATA[<p>Hi Rob,<br
/> To have the image change after a period of time, you could wrap the above code in its own function then use setTimeout to call it.<br
/> Example</p><p
class="code"><code><br
/> &lt;script type=&quot;text/javascript&quot;&gt;<br
/> function RandImg() {<br
/> var header = document.getElementById('header');<br
/> var pictures = new Array('images/image1.jpg','images/image2.jpg','images/image3.jpg','images/image4.jpg','images/image5.jpg');<br
/> var numPics = pictures.length;<br
/> if (document.images) {<br
/> var chosenPic = Math.floor((Math.random() * numPics));<br
/> header.style.background = 'url(' + pictures[chosenPic] + ')';<br
/> }<br
/> setTimeout(RandImg,2000);<br
/> }<br
/> window.onload = RandImg;<br
/> &lt;/script&gt;<br
/> </code></p><p>I&#8217;ve put an example here which changes the image every 2 seconds.<br
/> <a
href="http://www.elanman.co.uk/js_examples/random_image2.html" rel="nofollow">http://www.elanman.co.uk/js_examples/random_image2.html</a>.<br
/> Notice that sometimes the image doesn&#8217;t appear to change.<br
/> That&#8217;s because the same image can be selected randomly the next time the function is called. Having more images in the array will lessen the chances of this happening.</p> ]]></content:encoded> </item> <item><title>By: Rob Mason</title><link>http://www.elanman.co.uk/2008/09/random-header-image-with-javascript/comment-page-1/#comment-11</link> <dc:creator>Rob Mason</dc:creator> <pubDate>Wed, 18 Feb 2009 14:41:27 +0000</pubDate> <guid
isPermaLink="false">http://www.elanman.co.uk/?p=142#comment-11</guid> <description>Good article. Could you extend it to not only randomise the image, but also switch it after a set period of time to another random image?</description> <content:encoded><![CDATA[<p>Good article. Could you extend it to not only randomise the image, but also switch it after a set period of time to another random image?</p> ]]></content:encoded> </item> </channel> </rss>
