[EventCalendar] Re: Calendars stacking up in IE 7

Rob Hess robwhess at gmail.com
Wed May 30 19:20:26 UTC 2007


On 5/29/07, Rob Hess <robwhess at gmail.com> wrote:
> Hi,
>         I am using EventCalendar 3.1.1._rc1 with Wordpress 2.2.  I am
> getting a strange error in IE 7 under Windows XP.  When I first navigate to
> my website and click on the EC navigation links, instead of having the
> calendar for the next or previous month take the place of the calendar for
> the current month, the previous or next calendar shows up either above or
> below the one for the current month.  As I keep pressing navigation buttons,
> the calendars keep stacking up on top of each other instead of replacing the
> one that is currently there.
>         This only happens on my first entry to the site.  If I navigate to
> another page, the calendar works normally.  If I navigate back to the
> homepage, the calendar works normally.  The calendar works normally under
> Firefox.
>         To get a better idea of what is happening, visit my site:
> http://groups.engr.orst.edu/ewb/.  When you first enter the site using IE,
> try navigating through the calendar.
>         If anyone sees the same behavior, do you know what is happening?
> I've looked through the source a bit.  It looks like the function go_next()
> is called when the 'next' button is pressed.  In ec3.js, in function
> go_next(), on line 339, it looks like the current calendar is supposed to be
> hidden by setting its style.display field to 'none':
>
>     calendars[0].style.display='none';
>
> There is a similar statement on line 293 in go_prev().  I am not very
> proficient in JavaScript.  Is there any reason why this assignment might
> fail to have an effect under IE?


Hi.  If anyone is interested, I've tracked down the cause of this
problem.  This was not just an IE error.  It was present in other
browsers, too, but I just didn't browse in the right way to make it
appear in Firefox.
     The loadDates() function (line 189) uses an XMLHttpRequest object
to grab the dates for a new calendar.  For security reasons,
XMLHttpResuest.open() throws a "permission denied" exception for any
request from a domain different from the one from which the script was
called.  As it turns out, my webpage is available at two URLs:
http://groups.engr.orst.edu/ewb AND
http://groups.engr.oregonstate.edu/ewb.  My website's 'home' in WP is
set to the first, which causes the variable ec3.home to be set to the
same.  However, when I viewed my site using the second url and pressed
the next or prev buttons on my event calendar, it resulted in an
uncaught "permission denied" exception in loadDates at the
XMLHttpRequest.open() call at line 196.  This, in turn, resulted in
anything after the loadDates() calls at line 335 in go_next() and at
line 289 in go_prev(), including setting the old calendar's
style.display to 'none', to be skipped.  The end result was that the
old calendars never got hidden and kept stacking up on top of each
other in my sidebar.
     I attached a quick-fix patch that just catches the "permission
denied" exception in loadDates() and returns.  The result is that in
the rare case of one of these exceptions occurring, the old calendars
are still hidden from view.  However, the new event dates are never
obtained, and so their links do not show up in the new calendar.  I
guess this is a more aesthetically pleasing alternative than the old
bug, but it is still not a complete solution.  I don't know how many
other people have blogs that are available at more than one URL, so I
don't know if it is worth investing the time to develop a more robust
solution than this.  I was able to overcome my difficulty by defining
an ec3.alt_home variable and using it to request the new dates from
the second URL when I caught the "permission denied" exception.  This
probably also isn't the most robust solution.
     Anyway, I think eventcalendar3 is a great plugin.  I thank the
developers for their work.

-Rob

--- eventcalendar3_old/ec3.js   2007-02-15 05:23:20.000000000 -0800
+++ eventcalendar3/ec3.js       2007-05-30 11:49:57.069848000 -0700
@@ -193,8 +193,12 @@
     {
       ec3.reqs.push(req);
       req.onreadystatechange=process_xml;
-      req.open("GET",
-        ec3.home+'/?ec3_xml='+year_num+'_'+month_num,true);
+      try {
+        req.open("GET", ec3.home+'/?ec3_xml='+year_num+'_'+month_num,true);
+      }
+      catch(e) {
+        return;
+      }
       set_spinner(1);
       req.send(null);
     }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ec311rc1_xmlhttprequest.patch
Type: application/octet-stream
Size: 505 bytes
Desc: not available
Url : http://penguin.firetree.net/pipermail/eventcalendar/attachments/20070530/65f7afaf/ec311rc1_xmlhttprequest.obj


More information about the EventCalendar mailing list