Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-09-2008, 10:31 AM   PM User | #1
joey santiago
New to the CF scene

 
Join Date: Oct 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
joey santiago is an unknown quantity at this point
variable undefined only for IE

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:
Code:
<script type="text/javascript" src="fileLocation.js">
before closing the script tag i initialize my variables:
Code:
// 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:
Code:
<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...
joey santiago is offline   Reply With Quote
Old 10-09-2008, 11:03 AM   PM User | #2
vwphillips
Senior Coder

 
Join Date: Mar 2005
Location: Portsmouth UK
Posts: 4,358
Thanks: 3
Thanked 458 Times in 445 Posts
vwphillips is a jewel in the roughvwphillips is a jewel in the roughvwphillips is a jewel in the rough
best to provide a link to a page using the code
__________________
Vic

God Loves You and will never love you less.

http://www.vicsjavascripts.org.uk/

If my post has been useful please donate to http://www.operationsmile.org.uk/
vwphillips is offline   Reply With Quote
Old 10-10-2008, 01:12 AM   PM User | #3
Arty Effem
Banned

 
Join Date: May 2006
Location: England
Posts: 664
Thanks: 0
Thanked 84 Times in 84 Posts
Arty Effem can only hope to improve
Quote:
Originally Posted by joey santiago View Post
Code:
<script type="text/javascript" src="fileLocation.js">
before closing the script tag i initialize my variables:
Code:
// 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.

Code:
<script type="text/javascript" src="fileLocation.js"></script>
<script type="text/javascript">
var imgNumber = 0;
var NumberOfImages = 3;
....
</script>
Arty Effem is offline   Reply With Quote
Reply

Bookmarks

Tags
explorer, function, javascript, variable

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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

Forum Jump


All times are GMT +1. The time now is 03:49 AM.


Advertisement
Log in to turn off these ads.