0

I have a file SolarCalendar.htc, its contents are below:

<script language="javascript">
//My java Script Code
</script>

<public:property put=fnPutDay                  get=fnGetDay                name="day">
<public:property put=fnPutMonth                get=fnGetMonth              name="month">
<public:property put=fnPutYear                 get=fnGetYear               name="year">
<public:property put=fnPutMonthLength          get=fnGetMonthLength        name="monthLength">
<public:property put=fnPutDayLength            get=fnGetDayLength          name="dayLength">
<public:property put=fnPutFirstDay             get=fnGetFirstDay           name="firstDay">
<public:property put=fnPutGridCellEffect       get=fnGetGridCellEffect     name="gridCellEffect">
<public:property put=fnPutGridLinesColor       get=fnGetGridLinesColor     name="gridLinesColor">
<public:property put=fnPutShowDateSelectors    get=fnGetShowDateSelectors  name="showDateSelectors">
<public:property put=fnPutShowDays             get=fnGetShowDays           name="showDays">
<public:property put=fnPutShowTitle            get=fnGetShowTitle          name="showTitle">
<public:property put=fnPutShowVerticalGrid     get=fnGetShowVerticalGrid   name="showVerticalGrid">
<public:property put=fnPutShowHorizontalGrid   get=fnGetShowHorizontalGrid name="showHorizontalGrid">
<public:property put=fnPutValue                get=fnGetValue              name="value">
<public:property put=fnPutValueIsNull          get=fnGetValueIsNull        name="valueIsNull">
<public:property put=fnPutReadOnly             get=fnGetReadOnly           name="readOnly">
<public:property put=fnPutHoliday              get=fnGetHoliday            name="holiday">

<public:event id="onChange"         name="onchange">
<public:event id="onPropertyChange" name="onpropertychange">
<public:event id="onError"          name="onerror">

And I have SolarCalendar.htm file that uses this 'SolarCalendar.htc' as follows:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html XMLNS:IE>
    <head>
        <meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
        <meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
        <STYLE> IE\:Calendar  
            {
                behavior: url(SolarCalendar.htc) ;
                -moz-binding: url(bindings.xml#SolarCalendar.htc);
                 width : 100%; 
             }
        </STYLE>

    </head>
    <body onkeypress="Window_Keypress()" onload="Window_Onload()" onunload="Window_OnUnload()">
        <CENTER><IE:CALENDAR id="cal"></IE:CALENDAR></CENTER>
    </body>
</html>

But it doesn't work in FireFox (it works on IE). Do you know what is wrong in this code? I used bindings.xml in my project and simple examples with it work well, but the above code doesn't.

Wladimir Palant
  • 56,865
  • 12
  • 98
  • 126
vesna
  • 403
  • 1
  • 3
  • 13

1 Answers1

0

Can Firefox select your custom HTML element?

Does your selector for the <IE:CALENDAR> element work? You could try using the following styles, instead of the -moz-binding rule, and see if they have any effect:

IE\:Calendar {
    width: 100px;
    height: 100px;
    display: block;
    background-color: green;
}

If not, the selector (IE\:Calendar) may be the problem.

Is your filename correct?

Here’s your -moz-binding line:

-moz-binding: url(bindings.xml#SolarCalendar.htc);

If I understand correctly, that says:

Find the file “bindings.xml”, and within it, find the element with an id attribute of SolarCalendar.htc.

If your file is called “SolarCalendar.htc”, then Firefox won’t find it, because it’s not called “bindings.xml”.

Maybe you could take the XML content out of SolarCalendar.htc, and save it in a file called bindings.xml? Then remove #SolarCalendar.htc from your -moz-binding rule?

Paul D. Waite
  • 96,640
  • 56
  • 199
  • 270
  • D.Waite, yes,you're right.I just copy-paste from another place.I have my SolarCalendar.htc ,chould you tell me what I should write in 'SolarCalendar.htm' to work in firefix too? – vesna Mar 13 '12 at 08:22
  • @vesna: I’m saying you need a file called “bindings.xml”, and you need to put the XBL code (I’m guessing that all the `` tags are XBL, but I’m not familiar with XBL so I don’t actually know) into that file. Where did you get your original example code from? – Paul D. Waite Mar 13 '12 at 08:24
  • thanks @D.Waite I understand you.this code had been in project from past and works fine for years in IE.now my company decided that the project should works in FF,and I dont know how to use DHTML in firefox,and what changes I should do in code!! – vesna Mar 13 '12 at 08:29
  • @vesna: aha, oh dear, that doesn’t sound fun at all. I saw from [your other question](http://stackoverflow.com/questions/9679527/do-moz-behaviors-work-in-firefox-10) that Dean Edwards’ moz-behaviours script was an option for earlier versions of Firefox, but that XBL is no longer supported in web pages in Firefox. I don’t think there’s any other way to get the .htc code to work directly in Firefox — .htc is a Microsoft thing that other browsers haven’t adopted. – Paul D. Waite Mar 13 '12 at 10:14
  • @vesna: I’m not exactly sure what your .htc file does, but you might want to look at using an alternative widget in Firefox, e.g. [jQuery UI’s datepicker widget](http://jqueryui.com/demos/datepicker/)? Or [YUI’s](http://yuilibrary.com/yui/docs/calendar/)? – Paul D. Waite Mar 13 '12 at 10:16
  • D.Waite, thanks,but I have to change this code,could you tell me how to use .htc file in FireFox?if you get a sample I could handle it. – vesna Mar 13 '12 at 13:31
  • @vesna: Firefox does not support .htc. .htc is a Microsoft thing that other browsers haven’t adopted. – Paul D. Waite Mar 13 '12 at 14:29