Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Oct 2008
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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...

  • #2
    Senior Coder
    Join Date
    Mar 2005
    Location
    Portsmouth UK
    Posts
    4,505
    Thanks
    3
    Thanked 501 Times in 488 Posts
    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/Home.htm

    If my post has been useful please donate to http://www.operationsmile.org.uk/

  • #3
    Banned
    Join Date
    May 2006
    Location
    England
    Posts
    664
    Thanks
    0
    Thanked 84 Times in 84 Posts
    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>


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •