【问题标题】:Why doesn't -moz-binding work in my code?为什么 -moz-binding 在我的代码中不起作用?
【发布时间】:2012-03-29 15:02:16
【问题描述】:

我有一个文件SolarCalendar.htc,其内容如下:

<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">

我有SolarCalendar.htm 文件,它使用这个“SolarCalendar.htc”,如下所示:

<!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>

但它在 FireFox 中不起作用(它在 IE 上起作用)。你知道这段代码有什么问题吗?我在我的项目中使用了bindings.xml,并且使用它的简单示例运行良好,但上面的代码没有。

【问题讨论】:

  • 你的题目和题目有什么关系?

标签: css firefox dhtml dhtmlx


【解决方案1】:

Firefox 可以选择您的自定义 HTML 元素吗?

&lt;IE:CALENDAR&gt; 元素的选择器是否有效?您可以尝试使用以下样式,而不是 -moz-binding 规则,看看它们是否有任何效果:

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

如果不是,选择器 (IE\:Calendar) 可能是问题所在。

你的文件名正确吗?

这是您的-moz-binding 线路:

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

如果我理解正确,那就是:

找到“bindings.xml”文件,并在其中找到id属性为SolarCalendar.htc的元素。

如果您的文件名为“SolarCalendar.htc”,那么 Firefox 将找不到它,因为它不名为“bindings.xml”。

也许您可以从 SolarCalendar.htc 中取出 XML 内容,并将其保存在一个名为 bindings.xml 的文件中?然后从您的-moz-binding 规则中删除#SolarCalendar.htc

【讨论】:

  • D.Waite,是的,你是对的。我只是从另一个地方复制粘贴。我有我的 SolarCalendar.htc,你能告诉我应该在“SolarCalendar.htm”中写什么吗?也在firefix中工作?
  • @vesna:我是说你需要一个名为“bindings.xml”的文件,并且你需要放置 XBL 代码(我猜所有的 &lt;public:&gt; 标签都是 XBL,但是我不熟悉 XBL,所以我实际上不知道)到那个文件中。您从哪里获得原始示例代码?
  • 谢谢@D.Waite 我了解你。这段代码过去一直在项目中,并且在 IE 中运行良好多年。现在我的公司决定该项目应该在 FF 中运行,我不知道如何在 Firefox 中使用 DHTML,以及我应该在代码中做哪些更改!
  • @vesna:啊哈,天哪,这听起来一点也不好玩。我从your other question 看到,Dean Edwards 的 moz-behaviours 脚本是 Firefox 早期版本的一个选项,但 Firefox 的网页不再支持 XBL。我认为没有其他方法可以让 .htc 代码直接在 Firefox 中运行——.htc 是微软的东西,其他浏览器没有采用。
  • @vesna:我不确定你的 .htc 文件是做什么的,但你可能想看看在 Firefox 中使用其他小部件,例如jQuery UI’s datepicker widget?还是YUI’s
猜你喜欢
  • 2011-11-28
  • 2016-10-22
  • 2012-11-23
  • 2014-01-23
  • 2013-08-06
  • 2021-03-17
  • 2018-04-24
  • 2019-01-07
相关资源
最近更新 更多