...

View Full Version : variable undefined only for IE



joey santiago
10-09-2008, 10:31 AM
hello everybody,

i don't like javascript and usually try to avoid it... but now i need it and am having some troubles with it, so i hope someone can help me find out a nice solution.
I am using some simple functions to create a slideshow. These functions' code is in an external .js file which is called in my pages using:

<script type="text/javascript" src="fileLocation.js">
before closing the script tag i initialize my variables:


// Use the following variable to specify
// the number of images
var imgNumber = 0;
var NumberOfImages = 3;

var img = new Array(NumberOfImages);

// Use the following variables to specify the image names:
img[0] = "1.jpg";
img[1] = "2.jpg";
img[2] = "3.jpg";

i then call the functions through two links:

<a href="#" onclick="imgNumber=previm(imgNumber, NumberOfImages, img);return false;">
<img src="../../../immagini/prev.png" class="arrows" alt="" /></a>
<a href="#" onclick="imgNumber=nextim(imgNumber, NumberOfImages, img);return false;">
<img src="../../../immagini/next.png" class="arrows" alt="" /></a>
everything works on firefox, opera, konqueror, safari... but on Explorer 6 i got an error: imgNumber is undefined...

the only solution i found is to copy and paste the functions' code on every page. Of course i would like to avoid this for maintenance... and can't really understand why it doesn't work.
thanks a lot...

vwphillips
10-09-2008, 11:03 AM
best to provide a link to a page using the code

Arty Effem
10-10-2008, 01:12 AM
<script type="text/javascript" src="fileLocation.js">
before closing the script tag i initialize my variables:


// Use the following variable to specify
// the number of images
var imgNumber = 0;
var NumberOfImages = 3;
....Instead try doing that in a separate <script> element.


<script type="text/javascript" src="fileLocation.js"></script>
<script type="text/javascript">
var imgNumber = 0;
var NumberOfImages = 3;
....
</script>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum