Object 'is undefined'.... intermittent error...need a clue please.....

Hi All,

I use a great little Javascript Calendar component called JSCalendar. We have this running with 100s of users without a problem. On three machines we have encountered

'Calendar is undefined' which is really strange.

The first occurrence was with a desktop running IE5, and when updated to IE6 the issue went away.

We now have 2 laptops with the same problem, different site. These laptops are running IE6.0.29 on Windows 2000, patched to date, and apparently have the same config as all the desktops in the same company which all work fine... what????

So for the code.

In the <head> section I reference the Calendar code files.

<link href="../../../Js/Other/JSCalendar/calendar-theme.css" rel="stylesheet" type="text/css"/>      
<script type="text/javascript" src="../../../Js/Other/JSCalendar/calendar.js"></script>
<script type="text/javascript" src="../../../Js/Other/JSCalendar/lang/calendar-en.js"></script>
<script type="text/javascript" src="../../../Js/Other/JSCalendar/calendar-setup.js"></script>

In the body I have a textbox with an arrow image to the right of it which when clicked brings up the calendar. When you click on the calendar on the relevant date, the value goes into the textbox. The calendar is a CSS layer so no need for a popup.

This is the calling code in the <body>

<div id="FromDateValue">
<input id="tbFromDate" name="FromDate" style="width:157px;height:19px" type="text" class="REM_FormTextboxGo" value="01/01/2004" size="16" maxlength="20" onBlur="blnIsDirty=true;"/>
</div>
<div id="FromDateGo">
   <a id="HlImgFromDateGo" href="#">
      <img id="ImgFromDateGo" onClick="blnIsDirty=true;" src="../../../img/ddlb.gif" alt="Click Here to Pick up the date" border="0"/>
   </a>

   <script type="text/javascript">
    Calendar.setup({
        inputField     :    "tbFromDate",     // id of the input field
        ifFormat       :    "%d/%m/%Y",      // format of the input field
        daFormat       :    "%d/%m/%Y",      // format of the input field            
        button         :    "HlImgFromDateGo",  // trigger for the calendar (button ID)
        align          :    "Bl",           // alignment (defaults to "Bl")
        singleClick    :    true
    });
   </script>

</div>

I appreciate that you may be unfamiliar with this component, but I thought someone may have an idea of why this intermittent JS error would occur, expecially when 98% of the users are fine, so nothing intrinsically wrong with the app.

Any ideas would be hugely appreciated,

Sam


SamJollyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

GwynforWebCommented:
Is the script for  Calendar.setup javascript?
0
searlasCommented:
Probable cause is the machines failing to load the javascript.  The browser *should* wait till all those scripts are loaded before processing the rest of the page, but for a number of reasons this may not be happening (network/proxy issues; even a different subnet in an office might be enough to throw this out.)

Instead of calling the Calendar.setup inline as you are now, attach it as an 'onload' event to ensure the JS files it depends on have already loaded.

One question: does this 'Calendar is undefined' error occur everytime these few users load the page, or just the 1st time?  If it's everytime, it's likely the users concerned aren't allowing their browsers to cache anything.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
SamJollyAuthor Commented:
Yes it is,

There is a fair amount of code. I include some useful parts of it.

It starts like this:

Calendar.setup = function (params) {
      function param_default(pname, def) { if (typeof params[pname] == "undefined") { params[pname] = def; } };

      param_default("inputField",     null);
      param_default("displayArea",    null);
      param_default("button",         null);
      param_default("eventName",      "click");
      param_default("ifFormat",       "%Y/%m/%d");
      param_default("daFormat",       "%Y/%m/%d");
      param_default("singleClick",    true);
      param_default("disableFunc",    null);
      param_default("dateStatusFunc", params["disableFunc"]);      // takes precedence if both are defined
      param_default("mondayFirst",    true);
      param_default("align",          "Bl");
      param_default("range",          [1900, 2999]);
      param_default("weekNumbers",    true);
      param_default("flat",           null);
      param_default("flatCallback",   null);
      param_default("onSelect",       null);
      param_default("onClose",        null);
      param_default("onUpdate",       null);
      param_default("date",           null);
      param_default("showsTime",      false);
      param_default("timeFormat",     "24");


and laterly there seems to be some instantiation:

      var triggerEl = params.button || params.displayArea || params.inputField;
      triggerEl["on" + params.eventName] = function() {
            var dateEl = params.inputField || params.displayArea;
            var dateFmt = params.inputField ? params.ifFormat : params.daFormat;
            var mustCreate = false;
            var cal = window.calendar;
            if (!window.calendar) {
                  window.calendar = cal = new Calendar(params.mondayFirst,
                                               params.date,
                                               params.onSelect || onSelect,
                                               params.onClose || function(cal) { cal.hide(); });
                  cal.showsTime = params.showsTime;
                  cal.time24 = (params.timeFormat == "24");
                  cal.weekNumbers = params.weekNumbers;
                  mustCreate = true;
            } else {
                  cal.hide();
            }
            cal.setRange(params.range[0], params.range[1]);
            cal.params = params;
            cal.setDateStatusHandler(params.dateStatusFunc);
            cal.setDateFormat(dateFmt);
            if (mustCreate)
                  cal.create();
            cal.parseDate(dateEl.value || dateEl.innerHTML);
            cal.refresh();
            cal.showAtElement(params.displayArea || params.inputField, params.align);
            return false;
      };

I hope this helps.

really apreciate your input,

Sam
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

SamJollyAuthor Commented:
Searlas,

Just read your comments. Very interesting...

>>One question: does this 'Calendar is undefined' error occur everytime these few users load the page, or just the 1st time?  If it's everytime, it's likely the users concerned aren't allowing their browsers to cache anything.

Yes, it happens all the time. How can I reproduce this non caching behaviour - is there an IE setting that I can change?

I will comme bck to the onLoad solution after I have checked the Caching..

Thanks,

Sam
0
ZvonkoSystems architectCommented:
The question from searlas was: why it is not possible for you to call the Calendar.setup() from <body onLoad>
The creators of that calendar script do that in their pages.

My proposla is to do it in <body onLoad="Calender.setup()"> only for test on one of the failing workstations.
If it works with onLoad, then you know that you have a timing problem.

0
SamJollyAuthor Commented:
I am closing this now, as I think we have a lead on the solution.

Thanks to all,
Sam
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.