safari array issue

Discussion in 'JavaScript' started by mcdeere02, Aug 7, 2009.

Thread Status:
Not open for further replies.
  1. #1
    Hi,

    I'm running two arrays, the first one gives the quote (in red), the second (grey), who the quote was by.

    Safari, seems to be the only browser unable to show the second quote correctly, it only shows a single letter (although I only have ie, safari, firefox and opera)

    Why would this be?

    Is it a JavScript bug or do I have a Safari setting issue?

    the website is teamcherwell.com

    domdom
     
    mcdeere02, Aug 7, 2009 IP
  2. dimitar christoff

    dimitar christoff Active Member

    Messages:
    882
    Likes Received:
    62
    Best Answers:
    0
    Trophy Points:
    90
    #2
    you should use JSON for this - basically JSON is javascript object notation.

    
    var quotes = [
        {
            "quote": "The quick Brown Fox jumps over the lazy dog",
            "author": "Harold Pitman"
        },
        {
             "quote": "Some objects in javascript are also arrays!",
             "author": "Dimitar"
        }
    ];
    
    // same key:
    alert(quotes[1]['quote']); // Some objects in javascript are also arrays! 
    alert(quotes[1]['author']); // Dimitar
    
    PHP:
    can't not match this way.

    a piece of advice:

    do not use the constructor to make a new array, just do it direct.

    var foo = new Array(); -> var foo = [];
    var foo = [1,2,3,4,5];

    good luck learning js :)
     
    dimitar christoff, Aug 7, 2009 IP
Thread Status:
Not open for further replies.