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:35 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 10-30-2007, 10:49 AM Re: Function init not displaying images in firefox
logic ali's Avatar
Super Talker

Posts: 104
Trades: 0
Quote:
Originally Posted by mking View Post
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";
}
What does the Fx error console say? Use the same syntax to address the image that you used to test its presence. navimage is assumed to be a variable.
logic ali is offline
Reply With Quote
View Public Profile
 
Old 10-30-2007, 11:26 AM Re: Function init not displaying images in firefox
Junior Talker

Posts: 3
Name: Michelle
Trades: 0
I'm getting an error message that says:

navimage is not defined
[IMG]chrome://firebug/content/blank.gif[/IMG] navimage.src = "/images/nav/img_" + randomize + ".jpg";
mking is offline
Reply With Quote
View Public Profile
 
Old 10-30-2007, 12:40 PM Re: Function init not displaying images in firefox
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
It's because you didn't declared navImage.
Code:
function init() {
  if(document.images['navimage'] ) {
    var navImage=document.images['navimage'];
    var randomize = Math.round(Math.random()*29);
    navimage.src = "/images/nav/img_" + randomize + ".jpg";
  }
}
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
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.13381 seconds with 12 queries