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
Old 09-27-2009, 11:49 AM ImgArr2 is undefined
Ultra Talker

Posts: 254
Name: Daniel Mousdell
Trades: 0
Hey,

Recently I found out that my website seems to show a javascript warning in Internet Explorer - http://www.lilwaynehq.com - You can see the message in the screenshot below:



I know that it has something to do with my logo code (which I use to swap images every few seconds):

Code:
script language="JavaScript">
  var ImageArr1 = new Array("http://www.lilwaynehq.com/images/lilwaynehqlogo-800-big.jpg","http://www.lilwaynehq.com/images/lilwaynehqlogo2-800-big.jpg");
  var ImageHolder1 = document.getElementById('Rotating1');
  
  function RotateImages(whichHolder,Start)
  {
      var a = eval("ImageArr"+whichHolder);
      var b = eval("ImageHolder"+whichHolder);
      if(Start>=a.length)
          Start=0;
      b.src = a[Start];
      window.setTimeout("RotateImages("+whichHolder+","+(Start+1)+")",6500);
  }
  
  RotateImages(1,0);
  RotateImages(2,0);
  
</script>
Does anyone know how I can fix this?

Thanks, apperciate it
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

Last edited by Danaldinho; 09-27-2009 at 11:51 AM..
Danaldinho is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 09-27-2009, 03:08 PM Re: ImgArr2 is undefined
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
When I see this:
Code:
RotateImages(2,0);
and I look into the RotateImages function, I see that
the array it uses is based on the first parameter:
Code:
  function RotateImages(whichHolder,Start)
  {
      var a = eval("ImageArr"+whichHolder);
      var b = eval("ImageHolder"+whichHolder);
      if(Start>=a.length)
          Start=0;
      b.src = a[Start];
      window.setTimeout("RotateImages("+whichHolder+","+(Start+1)+")",6500);
  }
So, by calling "RotateImages(2,0)", you must have an ImageArr2 array and an ImageHolder2 element already defined with the images you want.

Otherwise, if you want 2 times the same image rotation, but in different placeholders, you will need to do something like
Code:
var ImageArr1 = ImageArr2
 = new Array("http://www.lilwaynehq.com/images/lilwaynehqlogo-800-big.jpg","http://www.lilwaynehq.com/images/lilwaynehqlogo2-800-big.jpg");
var ImageHolder1 = document.getElementById('Rotating1');
var ImageHolder2 = document.getElementById('Rotating2');
This will make the images arrays ImageArr1 and ImageArr2 identical, but give a specific placeholder for both.
__________________
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!
 
Old 09-27-2009, 03:31 PM Re: ImgArr2 is undefined
Ultra Talker

Posts: 254
Name: Daniel Mousdell
Trades: 0
Quote:
Originally Posted by tripy View Post
When I see this:
Code:
RotateImages(2,0);
and I look into the RotateImages function, I see that
the array it uses is based on the first parameter:
Code:
  function RotateImages(whichHolder,Start)
  {
      var a = eval("ImageArr"+whichHolder);
      var b = eval("ImageHolder"+whichHolder);
      if(Start>=a.length)
          Start=0;
      b.src = a[Start];
      window.setTimeout("RotateImages("+whichHolder+","+(Start+1)+")",6500);
  }
So, by calling "RotateImages(2,0)", you must have an ImageArr2 array and an ImageHolder2 element already defined with the images you want.

Otherwise, if you want 2 times the same image rotation, but in different placeholders, you will need to do something like
Code:
var ImageArr1 = ImageArr2
 = new Array("http://www.lilwaynehq.com/images/lilwaynehqlogo-800-big.jpg","http://www.lilwaynehq.com/images/lilwaynehqlogo2-800-big.jpg");
var ImageHolder1 = document.getElementById('Rotating1');
var ImageHolder2 = document.getElementById('Rotating2');
This will make the images arrays ImageArr1 and ImageArr2 identical, but give a specific placeholder for both.
Sorry, I didn't quite understand you there.

Should I basically do:

Code:
RotateImages(1,0);
Or what you said about the 2 ImageHolders?

Thanks
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
Danaldinho is offline
Reply With Quote
View Public Profile
 
Old 09-27-2009, 03:44 PM Re: ImgArr2 is undefined
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
What I say is that "RotateImages(1,0);" uses the images defined in
ImageArr1 to place them in the placeholder ImageHolder1.

If you use "RotateImages(2,0);", then you must have ImageArr2 and ImageHolder2 defined.
If you call "RotateImages(3,0);", then you will need ImageArr3 and ImageHolder3.

And so on.
If you want 2 rotators with the same images, you must define 2 arrays of images with the same content, and give different placeholders.
__________________
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!
 
Old 09-27-2009, 05:11 PM Re: ImgArr2 is undefined
Ultra Talker

Posts: 254
Name: Daniel Mousdell
Trades: 0
Thanks very much, that seemed to work.

But the bad news is that there is now another error:



Code:
<script language="JavaScript">
var ImageArr1 = ImageArr2
 = new Array("http://www.lilwaynehq.com/images/lilwaynehqlogo-800-big.jpg","http://www.lilwaynehq.com/images/lilwaynehqlogo2-800-big.jpg");
var ImageHolder1 = document.getElementById('Rotating1');
var ImageHolder2 = document.getElementById('Rotating2');
  
  function RotateImages(whichHolder,Start)
  {
  	var a = eval("ImageArr"+whichHolder);
  	var b = eval("ImageHolder"+whichHolder);
  	if(Start>=a.length)
  		Start=0;
  	b.src = a[Start];
  	window.setTimeout("RotateImages("+whichHolder+","+(Start+1)+")",6500);
  }
  
  RotateImages(1,0);
  RotateImages(2,0);
  
</script>
Do you know what this could be?

Thanks
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
Danaldinho is offline
Reply With Quote
View Public Profile
 
Old 09-27-2009, 05:54 PM Re: ImgArr2 is undefined
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
Nope, don't know, and running no windows boxes, I don't have a IE to test.
Sorry.
__________________
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!
 
Old 09-27-2009, 06:20 PM Re: ImgArr2 is undefined
Ultra Talker

Posts: 254
Name: Daniel Mousdell
Trades: 0
Oh okay then.

Does anyone else have any ideas how to fix this?

Thanks
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
Danaldinho is offline
Reply With Quote
View Public Profile
 
Old 10-01-2009, 07:56 AM Re: ImgArr2 is undefined
Ultra Talker

Posts: 254
Name: Daniel Mousdell
Trades: 0
Quote:
Originally Posted by Danaldinho View Post
Thanks very much, that seemed to work.

But the bad news is that there is now another error:



Code:
<script language="JavaScript">
var ImageArr1 = ImageArr2
 = new Array("http://www.lilwaynehq.com/images/lilwaynehqlogo-800-big.jpg","http://www.lilwaynehq.com/images/lilwaynehqlogo2-800-big.jpg");
var ImageHolder1 = document.getElementById('Rotating1');
var ImageHolder2 = document.getElementById('Rotating2');
  
  function RotateImages(whichHolder,Start)
  {
      var a = eval("ImageArr"+whichHolder);
      var b = eval("ImageHolder"+whichHolder);
      if(Start>=a.length)
          Start=0;
      b.src = a[Start];
      window.setTimeout("RotateImages("+whichHolder+","+(Start+1)+")",6500);
  }
  
  RotateImages(1,0);
  RotateImages(2,0);
  
</script>
Do you know what this could be?

Thanks
Anyone got any ideas?

Thanks
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
Danaldinho is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to ImgArr2 is undefined
 

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