Submit Your Article Webforumz RegistrationAnnouncements Contact Webforumz StaffContact
Home Resources Blogs Meet the Team Contact Register
 

Go Back   WebForumz.com > The Code > JavaScript

Reply
 
LinkBack Thread Tools
Old January 26th, 2009, 10:07 AM   #1
New Member
 

Join Date: Jan 2009
Location: London
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 geryzone is on a distinguished road
Angry Javascript : 2 Animated gifs changing on refresh

Hi there,

I was wondering if someone can help me with this one. I'm trying to get two animated gifs to change on refresh, unfortunately what I have below is not giving the expected result.

Thank you in advance!

JavaScript


<script type="text/javascript">
//<![CDATA[if (document.getElementById) { window.onload = swap }; function swap() {
var numimages=2; rndimg = new
Array("images/panel/greece_129-x-143.gif",
"/images/panel/greece_129-x-143.gif";
x=(Math.floor(Math.random()*numimages)); randomimage=(rndimg[x]);
document.getElementById("eventad").style.backgroun dImage = "url("+
randomimage +")"; }//]]>

</script>


CSS

#eventad {
height:144px; width:129px;
border:0px solid #000;
background:#fff url(/newftbportal/images/panel/athens_129-x-143.gif) no-repeat center center;
text-indent:-9999px;
}
geryzone is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old January 27th, 2009, 07:37 AM   #2
New Member
 

Join Date: Jan 2009
Location: Kerala, India
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 sands is on a distinguished road
Re: Javascript : 2 Animated gifs changing on refresh

Correct code is:
Code:
<script type="text/javascript">
//<![CDATA[
if (document.getElementById) { window.onload = swap; }
function swap() {
var numimages=2; rndimg = new
Array("images/panel/greece_129-x-143.gif","/images/panel/greece_129-x-143.gif");
x=(Math.floor(Math.random()*numimages)); randomimage=(rndimg[x]);
document.getElementById("eventad").style.backgroundImage = "url(" + randomimage +")"; }
//]]>
</script>
sands is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to stop the browser refresh on clicking the webbrowser's refresh button ? camarun20 JavaScript 3 March 18th, 2008 08:04 PM
refresh using javascript SirChinjin JavaScript 0 May 19th, 2007 03:41 PM
Gifs? PSIR Graphic Specifics 1 November 3rd, 2006 02:02 PM
Changing css with page refresh krrish HTML, XHTML and CSS 3 July 26th, 2006 04:20 AM
Changing pseudo class state with JavaScript? MarcMiller JavaScript 1 February 4th, 2006 09:10 AM


Search Engine Optimization by vBSEO 3.2.0 RC8