Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Function init not displaying images in firefox
Old 10-29-2007, 06:33 PM Function init not displaying images in firefox
Junior Talker

Posts: 3
Name: Michelle
Trades: 0
Hello all,

I'm using an init function to randomly rotate an image every time the page is loaded. This works in IE but not in firefox. Any ideas? The code is below. Thanks in advance for your help.

function init() {
if(document.images['navimage'] ) {
var randomize = Math.round(Math.random()*29);
navimage.src = "../images/nav/img_" + randomize + ".jpg";
}
mking is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 11-02-2007, 11:59 AM Re: Function init not displaying images in firefox
Novice Talker

Posts: 14
Name: Jared
Trades: 0
Well, I'm not sure about your code, but I know a javascript banner rotating script that works just fine.

If you want to use it, here it is:

banner.js:
Code:
<!--
dir = 'IMAGE DIRECTORY';
bannerImages = new Array;

//Array of banner images
bannerImages[0] = 'banner.gif';
bannerImages[1] = 'banner2.gif';
bannerImages[2] = 'banner3.gif';
bannerImages[3] = 'banner4.gif';

onload=function() {

  var rndNum =Math.floor(Math.random() * bannerImages.length);
 

  document.images['placeholder'].src = dir + bannerImages[rndNum];
}
-->
Don't forget to change the image directory to whatever it is, and put the banner.js in the same directory.

somepage.html:
Code:
<html>
 <head>
  <title>site title</title>
  <script type="text/javascript" src="IMAGE DIRECTORY/banner.js"></script>
 </head>
 <body>
  <div id="banner">
   <img src="IMAGE DIRECTORY/banner.gif" alt="" width="596" height="120" name="placeholder" />
  </div>
 </body>
</html>
ArsonistX is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Function init not displaying images in firefox
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.09716 seconds with 12 queries