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

Posts: 3
Name: Michelle
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
 
When You Register, These Ads Go Away!
Old 10-30-2007, 09:49 AM Re: Function init not displaying images in firefox
logic ali's Avatar
Skilled Talker

Posts: 85
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.
__________________
556E677261746566756C204261737461726473
logic ali is offline
Reply With Quote
View Public Profile
 
Old 10-30-2007, 10:26 AM Re: Function init not displaying images in firefox
Junior Talker

Posts: 3
Name: Michelle
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, 11:40 AM Re: Function init not displaying images in firefox
tripy's Avatar
Fetchez la vache!

Posts: 2,054
Name: Thierry
Location: In the void
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";
  }
}
__________________
Listen to the ducky: "This is awesome!!!"

tripy is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Function init not displaying images in firefox
 

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

vB 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.12109 seconds with 12 queries