DD_belatedPNG.js - 如何访问 vml 对象?这是一个 PNG 图像交换
我正在尝试使用 Drew Dillard 出色的 DD_belatedPNG 修复 + jQuery 来实现悬停时的普通图像交换 - 但使用 PNG,并在 IE6 上工作。
由于 DD 的脚本设置原始图像的可见性为“隐藏”,您无法有效地将鼠标悬停在其上。我注意到,很多人都受到这个限制的阻碍。足以让 Drew 提到他将尝试在下一版本的 PNG 修复中找到解决方法。
好吧,与此同时,我认为我可以通过处理图像父级上的悬停事件来解决这个问题。因此,在鼠标悬停时,我会隐藏由 DD_belatedPNG 创建的 VML 对象,同时在“thelink”上设置背景图像,而在鼠标悬停时,再次显示 VML 对象并将背景图像设置为空。
下面的代码只是为了看看我是否可以访问VML对象,但它在VML上不起作用。它隐藏了所有其他子项,但不隐藏 VML。有什么想法吗?
$(document).ready(function(){
$("thelink").hover(function() {
$(this).children().attr({
style: "visibility:hidden"
});
}, function() {
$(this).children().attr({
style: "visibility:visible"
});
});
});
或者,有人可以建议一个很棒的 PNG 图像交换方法吗?我知道您可以交换链接的背景图像。但你仍然需要在 A 标签内添加一些内容。那不是我的情况。另外,你可以在A标签中放置一个透明的GIF并交换背景图像来达到效果,但我真的不想这样做。感谢您的见解!
I am trying to use Drew Dillard's awesome DD_belatedPNG fix + jQuery to achieve a run-of-the-mill image-swap on hover -- but with PNGs, and to work on IE6.
Example: <a id="thelink" href="blah.html"><img src="f-u-ie6.png" /></a>
Since DD's script sets the visibility of the original image to "hidden", you can't effectively hover over it. A lot of people, I have noticed, are thwarted by this limitation. Enough so that Drew mentioned he would try to get a work-around into the next version of his PNG fix.
Well, in the meantime, I thought I could get around this by handling the hover event on the image's parent instead. So onmouseover, I would hide the VML object created by DD_belatedPNG while setting a background image on "thelink", and onmouseout, show the VML object again and set the background image to nothing.
The following code was just to see if I could access the VML object, but it does not work on the VML. It hides all manner of other children, but not the VML. Any ideas?
$(document).ready(function(){
$("thelink").hover(function() {
$(this).children().attr({
style: "visibility:hidden"
});
}, function() {
$(this).children().attr({
style: "visibility:visible"
});
});
});
Alternatively, can anyone suggest a great PNG image-swap method? I know that you can swap a background image of a link. But you still need to have something inside the A tag. That's not my case. Also, you could put a transparent GIF in the A tag and have the background image swapped to achieve the effect, but I really don't want to do that. Thanks for your insights!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
查看innerHTML(在浏览器地址栏中使用javascript)并查看生成VML对象的代码后,该对象在使用DD_belatedPNG 修复后,我决定采取不同的策略。
我现在使用 TwinHelix 的 IE PNG 修复。我在 A 标记中同时具有关闭和开启状态 PNG,但开启状态图像设置为
display: none
。我正在使用 jQuery 来切换这些图像。请参阅我的其他帖子对于具体的代码。所有这些都是为了确保我的 PNG 翻转在 IE6 中工作。
After looking at the innerHTML (using javascript in the browser address bar) and seeing the code that generates the VML object which displays my PNG when using the DD_belatedPNG fix, I decided to take a different tack.
I am now using TwinHelix's IE PNG Fix. I have both OFF and ON state PNGs in the A tag, but the ON state images are set to
display: none
. I am using jQuery to toggle these images. See my other post for specific code.All this to make sure my PNG rollovers work in IE6.