Demo of David Oberst's modified "calendar.js" for ZIP's calendar problem with Safari
The problem with Apple's Safari browser and the popup calendar on the ZipList page is that it uses an "IFRAME" with a CSS display style of "none" to hide it until it is popped up. Safari apparently has a bug/quirk where IFRAMES hidden in this way (bug ref #1, bug ref #2), so that a hidden frame doesn't seem to "exist" as far as the Javascript DOM is concerned (it doesn't appear in the "Frames" collection and is not otherwise addressable). This causes problems for the code in ZIP's calendar drawing routine (contained in calendar.js), which assigns the HTML for the calendar to the "innerHTML" property. Since the frame is still hidden by the "display:none" style at the time, it can't be accessed by Javascript and the assignment fails, causing the calendar popup code to abort.
My solution is to swap the order of the two lines of code in the "Calendar.prototype.show" method which call the HTML construction routine ("Calendar.prototype.buildstring") and then unhide the frame. By unhiding the frame first, it becomes accessible for the "buildstring" routine to make the assignment.
There is a second problem in that the syntax of the assignment used by ZIP does not seem to work with Safari, even once the frame is visible. ZIP uses
this.containerLayer.contentWindow.document.body.innerHTML = str;
which seems to fail for some reason with Safari (it appears that "containerLayer" doesn't have the "contentWindow" property). I've included a check for this in my modified "calendar.js" file (it is in the "Calendar.prototype.writestring" routine). If "contentWindow" isn't available, we instead use the code
myFrame = frames['calendarWindow'];
My test case below does work, but for some reason in Safari the calendar doesn't have the CSS style applied to it, which makes it look somewhat ugly. This may be something to do with the way I set the test up, since a more minimal test of IFRAME manipulation seems to have no problem. In any case, it does work, which is better than the current non-functioning ZIP version. Unless these minor changes to calendar.js (marked with "DVO" comments) have some sort of side effect on other browsers (I wouldn't think so), it should be possible to incorporate the two changes into the ZIP site and have the popup calendar finally work with Safari.
myFrame.document.body.innerHTML = str;
![]()