JavaScript not working in Safari

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • computerfox
    Contributor
    • Mar 2010
    • 276

    #1

    JavaScript not working in Safari

    Hello everyone,

    I'm not sure if it's just my copy of Safari (Lion) or not, but for some reason the following doesn't work:

    Code:
    
    $(document).ready(function(){
    
    
    var audio=document.querySelector("audio");
    audio.src="playlists/music/"+song[i];
    
    audio.volume = audio.volume - .6;
    
    
    audio.load();
    audio.play();
    
    $("#nowplaying").text(song[i]);
    $("#next").text(song[i+1]);
    //});
    
    
    audio.addEventListener('ended',function(){
    
    //alert(i);
    
    audio=document.querySelector("audio");
    
    audio.src="playlists/music/"+song[i+1];
    //alert(song[i]);
    
    audio.load();
    audio.play();
    
    i++;
    
    //alert(song.length); 
    //alert(i);
    
    
    $("#song").text("playlists/music/"+song[i]);
    
    $("#nowplaying").text(song[i]);
    $("#next").text(song[i+1]);
    
    if(i==song.length){
    
    i=0;
    
    audio.src="playlists/music/"+song[i];
    
    $("#song").text("playlists/music/"+song[i]);
    
    $("#nowplaying").text(song[i]);
    $("#next").text(song[i+1]);
    
    
    }
    
    },false);
    
    
    });
    });
    It's suppose to move the playlist to the next song. I don't get any errors, it just doesn't move i. It works in every other browser, just not Safari, which is weird because it use to before.

    Any ideas?
  • computerfox
    Contributor
    • Mar 2010
    • 276

    #2
    Some updates-I tried troubleshooting what was going on and it's not even Safari. It's actually my operating system (Lion).



    edit: it's actually the combination of Safari in Lion. Lion seems to have a bug with JavaScript.

    Comment

    Working...