I pass a Date object to a method which calls date.getHours() or any other method such as date.getFullYear() and it throws an error "Can't execute code from a freed script". It seems that IE9 does not properly support date objects used by date picker.
I’m new to javascript/general coding and have had a problem which only seems to occur in IE9. I am warning everybody about this as I may have gone about solving it in completely the wrong way…
I tried various different things in an attempt to solve this problem, such as:
if (date.getHours()=="undefined") {
var localDate = new Date(date);
var hours = localDate.getHours();
// etc
}
I now have a solution (it may not be the best, but it does the job) and will post it below, however I would like to know if anybody else has encountered the same problem and how they have resolved it?
In my experience, the problem happens when the Date object you’ve got was constructed in a different window, such that since its construction that other window has been closed or reloaded with a new page.
The solution is to send object inter-window in some string form, reconstituting them as necessary in the destination context.
(It isn’t just Date instances of course; it’s any object type. Primitives don’t have the problem, if I recall.)