views:

67

answers:

1

Hi. I have a javascript that, when you finish to watch a video, it redirect you in another website. It runs good on IE and Firefox, but not run on Google Chrome and Apple Safari. Can anyone help me to find the problem? Many thanks.

var currentState = "NONE";
var previousState = "NONE";

var player = null;

function playerReady(thePlayer) {
    player = document.getElementById(thePlayer.id);
    addListeners();
}


function addListeners() {
    if (player) {
        player.addModelListener("STATE", "stateListener");
    } else {
        setTimeout("addListeners()", 100);
    }
}

function stateListener(obj) { //IDLE, BUFFERING, PLAYING, PAUSED, COMPLETED
    currentState = obj.newstate;
    previousState = obj.oldstate;

    var tmp = document.getElementById("stat");
    if (tmp) {
        tmp.innerHTML = "current state: " + currentState 
                      + "<br>previous state: " + previousState;
    }

    if ((currentState == "COMPLETED")) {
        document.location.href = "http://www.google.com";
    }
}
A: 

Can anybody help me?

Marco