If I define the following constructor and method, I can call deck.tracker = new ActivityTracker(); without error:
function ActivityTracker() {}
ActivityTracker.prototype = {
trackEvent: function () {}
}
If I add the code inside an if-statement (to limit the code to a local server):
if (window.location.href.indexOf("http://0.0.0.0") == 0 ||
window.location.href.indexOf('http://local') == 0) {
function ActivityTracker() {}
ActivityTracker.prototype = {
trackEvent: function () {}
}
};
the console returns: Uncaught TypeError: ActivityTracker is not a constructor. I have made sure, that the if-condition returns true.
Any idea what could be the cause?
Aucun commentaire:
Enregistrer un commentaire