如何让 -moz-binding 用于带有 data:text/xml 的省略号?

发布于 2024-09-03 13:21:57 字数 1533 浏览 4 评论 0原文

我正在开发的项目中有很多元素都使用省略号样式,当然,除了 FireFox 之外,这些元素在所有主要浏览器中都可以与纯 CSS 配合使用。我们实现了 -moz-binding 修复,它引用带有绑定信息的 xml 文件,用于裁剪使用 XUL/XBL 定义的元素,如定义的 这里并且效果很好...直到我们决定将所有静态文件(CSS、图像等)移动到性能优化的服务器上。 -moz-绑定不再起作用,因为作为安全预防措施,FF 已禁用 XUL 跨域工作。

我在网上找到了很多关于将绑定 xml 直接放入 -moz-binding 的 url 子句中的参考资料,如下所示:

-moz-binding: url(data:text/xml;charset=utf-8,%3C%3Fxml%20version%3D%221.0%22%3F%3E%3Cbindings%20xmlns%3D%22http%3A//www.mozilla.org/xbl%22%20xmlns%3Axbl%3D%22http%3A//www.mozilla.org/xbl%22%20xmlns%3Axul%3D%22http%3A//www.mozilla.org/keymaster/gatekeeper/there.is.only.xul%22%3E%09%3Cbinding%20id%3D%22ellipsis%22%3E%3Ccontent%3E%3Cxul%3Adescription%20crop%3D%22end%22%20xbl%3Ainherits%3D%22value%3Dxbl%3Atext%22%3E%3Cchildren/%3E%3C/xul%3Adescription%3E%3C/content%3E%3C/binding%3E%3C/bindings%3E);

但这不起作用...绑定失败并且该元素根本不会在浏览器中显示。没有抛出错误(我至少可以弄清楚如何捕获),因此我无法诊断发生了什么。

我想也许这只是我编码 xml 的方式,但甚至在 Mozilla 文档 或此其他示例 对我不起作用。我尝试过简单的 html 页面,除了 Mozilla 示例的元素之外什么都没有,但失败了。我在配置方面缺少什么来使这个内联的东西工作?

我要么寻找 1) 一种使内联 -moz-binding 工作的方法,要么 2) 一种解决它的方法,以便当 CSS 来自另一个域时外部 xml 文件可以工作。

如果有人有建议,我们将不胜感激!

顺便说一句,我对将省略号应用于字段的任何其他解决方案(例如 Javascript 实现)不感兴趣。这对于我们的目的来说效果很好,并且在站点中作为 CSS 类使用了太多地方,使得重构另一种方法变得可行。

We have a lot of elements on the project I am working on that use ellipsis styles, which, of course, work fine with pure CSS in all major browsers but FireFox. We implemented the -moz-binding fix for that which references the xml file with the binding information for cropping an element defined with XUL/XBL as defined here and it worked great... Until we decided to move all our static files (CSS, images, etc) to performance optimized servers. The -moz-bindings no longer worked because FF has disabled XUL from working cross-domain as a security precaution.

I found a lot of references online about putting the binding xml directly into the url clause of the -moz-binding like this:

-moz-binding: url(data:text/xml;charset=utf-8,%3C%3Fxml%20version%3D%221.0%22%3F%3E%3Cbindings%20xmlns%3D%22http%3A//www.mozilla.org/xbl%22%20xmlns%3Axbl%3D%22http%3A//www.mozilla.org/xbl%22%20xmlns%3Axul%3D%22http%3A//www.mozilla.org/keymaster/gatekeeper/there.is.only.xul%22%3E%09%3Cbinding%20id%3D%22ellipsis%22%3E%3Ccontent%3E%3Cxul%3Adescription%20crop%3D%22end%22%20xbl%3Ainherits%3D%22value%3Dxbl%3Atext%22%3E%3Cchildren/%3E%3C/xul%3Adescription%3E%3C/content%3E%3C/binding%3E%3C/bindings%3E);

But that didn't work... the binding just fails and the element does not display at all in the browser. No error (that I can figure out how to capture at least) is thrown and so I can't diagnose what's going on.

I thought maybe it was just the way I encoded the xml but even trying the sample on the Mozilla documentation or this other sample doesn't work for me. I have tried simple html pages with nothing but an element with the Mozilla example and it fails. What is it I am missing configuration-wise to make this inline stuff work?

I am either looking for 1) a way to make the inline -moz-binding work or 2) a way to resolve it so that the external xml file works when the CSS is coming from another domain.

If anyone has advice it is much appreciated!

By the way, I'm not interested in any other solutions in applying ellipsis to fields (such as Javascript implmentations). This works fine for our purposes and is used too many places in the site as a CSS class to make a refactoring for another approach feasible.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

调妓 2024-09-10 13:21:57

您可以尝试在 .htaccess 中添加:

Header set Access-Control-Allow-Origin * 

source

You could try that adding in your .htaccess:

Header set Access-Control-Allow-Origin * 

source

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文