Reputation: 8548
I have this script and it runs fine in chrome (and in JS online validators) but firefox throws me this error:
screen.initialize is not a function
Is this syntax somehow not in accordance with standards?
$(document).ready(function() {
screen = new Screen('t543f3r','user1','screen4',5);
screen.initialize();
}
Here is the Screen class:
//Our screen object
function Screen(hashKey,username,screenName,layout) {
this.hashKey = hashKey;
this.username = username;
this.screenName = screenName;
this.layout = layout;
//this.cacheRefreshInterval = 1000*60*5;
this.checkLayoutInterval = 1000*60*5; //check for new cache every 5 minutes
}
Screen.prototype.initialize = function() {
var self = this;
console.log('initializing screen '+this.screenName+' (layout is ['+this.layout+']) on player '+this.username+' using key '+this.hashKey);
var time = self.checkLayoutInterval;
setTimeout(function(){self.getValidLayout();}, time);
console.log('getValidLayout() set for '+time);
}
Screen.prototype.getValidLayout = function() {
var self = this;
var url = self.findBaseUrl(true) + 'getValidLayout/'+self.hashKey;
jQuery.ajax({
async: true,
url: url,
success: function(result) {
console.log('successfully fetched the valid screen layout: ['+result+']');
if (result != self.layout) {
window.location.reload();
}
},
error: function(result) {
console.log('there was an error fetching the screen layout');
},
complete: function() {
//setup next check
var time = self.checkLayoutInterval;
setTimeout(function(){self.getValidLayout();}, time);
console.log('next getValidLayout() set for '+time);
}
});
}
Upvotes: 0
Views: 57
Reputation: 35074
window.screen
is a readonly property. When you assign to it (because you didn't declare your screen
as a var), the assignment gets ignored.
Upvotes: 1