SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Oct 2001
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Javascript: undefined -constant browser compatibility?

    Hi all.

    I'm having a little problem with a site of mine.. On one page I have a list of items, which are defined in a .js file, in arrays. Separate arrays are used to store different information about my items.. Like:

    --8<--

    id = new Array;
    info = new Array;

    id[id.length]="firstItem";
    info[info.length]="Info on the first item";

    id[id.length]="secondItem";
    info[info.length]="Info on the second item";

    --8<--

    So it's a really simple database of sorts. My problem is that I have items where some of the properties are undefined, and I used the undefined constant in JS for that. If I didn't assign a value to the array that doesn't have a "real" value, using array.length for new items wouldn't work right.

    The page works just fine in IE 5.0 and up, Netscape 6, and Opera 5, but I have gotten a few error reports(that aren't really informative) from people using IE 4. They're getting runtime errors.. I don't have access to a machine with IE 4 so I could reproduce this problem.

    So, is the undefined -constant not compatible with older browsers? I can't figure out what else could be causing this problem, since the rest of the JS I'm using is pretty basic. Am I going to have to rewrite my scripts to use something else than undefined?

    Thanks in advance.

  2. #2
    What? Maelstrom's Avatar
    Join Date
    Oct 2001
    Location
    Whistler BC originally from Guelph Ontario
    Posts
    2,175
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well there are a couple of things (sorry new to the group and I can't get the quote to go on .

    When you define your Arrays you are leaving out the ()

    var id=new Array();
    var info=new Array();

    type of thing.

    That should do it as I didn't see anything else wrong. The constants should default to the correct number of the array. The only thing I can think of is if they are using prowser pre ver 3.0 if thats true than I will go into more detail.

    Maelstrom
    Maelstrom Personal - Apparition Visions
    Development - PhP || Mysql || Zend || Devshed
    Unix - FreeBSD || FreeBsdForums || Man Pages
    They made me a sitepoint Mentor - Feel free to PM me or Email me and I will see if I can help.


Bookmarks

Posting Permissions

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