HTML组件(HTML conponent)是DTHML里的东西,相信现在大部分的web开发或者是网站都不使用DHTML了。它只能在IE下有直接的支持,它直接在样式表中用

behavior: url(htcfilename.htc);

来指示样式的行为使用的htc文件,IE支持behavior,但火狐不能支持。

如何让火狐等浏览器也支持htc呢,这里有个已实现的示例:

此方法来自http://dean.edwards.name/

它的示例http://dean.edwards.name/my/examples/moz-behaviors/

示例下载http://deanedwards.googlecode.com/svn/trunk/download/moz-behaviors.zip

下面以他的示例来解释下实现方法。

1.         IE下是在样式表中用behavior,那么火狐下有它自己专用的css,那就是用-moz-binding,最终css就是这样的:

/* 用于IE的 behaviors */
behavior: url(drag-box.htc);
/* 用于火狐的 behaviors */
-moz-binding: url(bindings.xml# drag-box.htc);

2.         发现css中有个bindings.xml文件全名,这个就是作者写的xml文件,其中主要是有两个地方是重要的,其他的可以不管它(除非你也需要)。

<!—此处最重要,意思就是用moz-behaviors.xml来提供对behavior的支持(moz-behaviors.xml中有解析htc文件的javascript代码)-->
<binding id="behavior" extends="moz-behaviors.xml#behavior"/>
<!—类似这些都是用来标识需要用到的htc文件的 -->
<binding id="test.htc" extends="#behavior"/>

相关文章:

  • 2022-12-23
  • 2021-12-05
  • 2021-05-02
  • 2021-09-19
  • 2021-11-01
  • 2021-07-21
  • 2021-09-02
猜你喜欢
  • 2022-12-23
  • 2021-08-31
  • 2021-12-17
  • 2022-12-23
  • 2021-12-28
  • 2022-12-23
  • 2021-10-04
相关资源
相似解决方案