This very basic script creates 3 variables to use on pages, today date in a preferred format, a date +90 days from today and a date +120 days from today.
It works great on Firefox and IE, however in Chrome those variables come up as “undefined” and console outputs this:
“Uncaught TypeError: Object false has no method ‘setDate'”
Here is my JavaScript
var today = new Date();
var rg = (today.getMonth()+1) + "/" + today.getDate() + "/" + today.getFullYear();
var closed = new Date();
closed.setDate(today.getDate()+90);
var cl = (closed.getMonth()+1) + "/" + closed.getDate() + "/" + closed.getFullYear();
var expire = new Date();
expire.setDate(today.getDate()+120);
var ex = (expire.getMonth()+1) + "/" + expire.getDate() + "/" + expire.getFullYear();
closedis a reserved name for anywindowobjects. (see here) Since you’re running this in the global space all variables are stored underneathwindow, so you’re running into collision with what the browser thinkswindow.closedshould be.Simply change
var closed = new Date();to a new name or as @KingKongFrog suggests place it in a new scope via a closure.