我的问题是关于 jQuery 支持 系统。
我想知道是否可以使用这种方法判断浏览器是否支持半透明背景PNG图像。
编辑:我对特定问题的 CSS 解决方案不感兴趣。 我想知道 jQuery 支持检查系统是否可以检查这一点。 我很欣赏这个建议,但我正在尝试找出有关 jQuery 支持功能的具体信息。
My question is regarding the jQuery Support system.
I'd like to know if it is possible to tell whether or not the browser will support semi-transparent background PNG images using this method.
Edit: I am not interested in CSS solutions to a specific problem. I'd like to know if the jQuery support checking system can check this. I appreciate the advice but I'm trying to find out a specific bit of information about the support
feature of jQuery.
发布评论
评论(5)
我不使用 Js 来做这类事情...
我使用
jQuery 已弃用 jQuery 1.3 中的浏览器检查。 我不确定他们什么时候会完全删除它。
我强烈建议将此检查留给 CSS 和/或 条件样式表。
在 JS 中,无法在不检查浏览器的情况下检查是否支持 alpha 透明度。
I don't use Js for this sort of thing...
I use
jQuery have deprecated the browser checking in jQuery 1.3. I'm not sure when they will entirely remove it though.
I would highly recommend leaving this checking up to CSS and/or conditional stylesheets.
There is no way to in JS to check for the ability to support alpha transparency without checking browsers.
我认为这根本不可能,毕竟即使IE6显示透明png,它也只是不显示透明度; 所有浏览器都“支持” png,因此您无法检查它。
如果您可以获得页面上特定像素的颜色,当然可以,但似乎这是不可能做到的。
另请参阅 Javascript - 从画布元素下的图像获取像素数据?< /a>
I think that is simply not possible, after all, even IE6 shows the transparent png's, it just does not show the transparency; all browsers "support" png's so you can´t check for that.
If you could get the color of a specific pixel on a page, you could of course, but it seems that is impossible to do.
See also Javascript - get pixel data from image under canvas element?
也许您可以使用 jQuery pngFix 或 jQuery ifixpng?
如果这些都不起作用,我建议改为查看条件注释,如 MSDN。
Maybe you could just use jQuery pngFix or jQuery ifixpng?
If neither of those will do, I'd suggest looking into conditional comments instead, as documented at MSDN.
我想我明白你在追求什么,因为我正在尝试做类似的事情:
如果支持 alpha PNG,请使用 jQuery 插入 PNG。 否则,什么也不做。
我能想到的唯一解决方案是使用 jQuery 插入 DIV。 然后,在 CSS 中将 DIV 的 background-iamge 设置为要使用的 PNG,后跟条件注释以向 IE6 提供透明的 gif。
我还没有尝试过,但它应该可以解决问题。
I think I understand what you're after TM, since I'm trying to do something similar:
If alpha PNG is supported, insert a PNG using jQuery. Otherwise, do nothing.
The only solution I can think of is inserting a DIV using jQuery. Then, in the CSS you set the DIV's background-iamge to the PNG you want to use followed by a conditional comment to feed IE6 a transparent gif instead.
I haven't tried it out yet but it should do the trick.
使用 javascript 修复 png 是不好的做法。 您最终会看到一闪而过的无样式内容。 CSS 和条件注释将是更好的选择。
你可以使用alex的方法。
Fixing pngs with javascript is bad practice. You’ll end up with a flash of unstyled content. CSS and conditional comments would be a better choice.
You can use the method of alex.