Cufon 导致 Internet Explorer 延迟
我正在使用外部呈现的控件在网页上创建菜单。该控件来自 cms 系统,无法修改。当调用 Cufon.replace() 来更改菜单项的字体时,我们注意到 IE8 中存在闪烁效果,就像存在某种延迟一样。在 FireFox 4 和 Chrome 中,这种效果不可见。我读过 stackoverflow 上的其他主题,但似乎没有一个与这个问题相似。它仅在将鼠标悬停在菜单项上时发生。
我们熟悉这样一个事实:Cufon 需要在需要更改字体的 html 元素之后直接调用。这还有必要吗?或者我需要在某个地方调用 Cufon.Now() 吗?当我将鼠标悬停在菜单项上时,是什么导致了闪烁效果?
<cc1:MenuBuilder ID="Mainmenu" MenuName="Mainmenu" runat="server" CssClass="menubar-nav-list" UseDiv="true" ShowLevels="1" />
<script language="javascript" type="text/javascript">
Cufon.replace('#Mainmenu .menuitem', { fontFamily: 'DIN Eng', hover: true });
</script>
I'm using an externally rendered control to create an menu on a webpage. The control is coming from an cms system and can't be modified. When calling Cufon.replace() to change the font of the menu items provided we notice an flickering effect in IE8, like there is some sort of delay. In FireFox 4 and Chrome this effect isn't visible. I've read other topics on stackoverflow about it, but none seem to look similar to this problem. It only occurs on hovering over the menu item.
We're familiar with the fact the Cufon needs to be called straight after the html-element of which the font needs to be changed. Is this still necessary? Or do I need to call a Cufon.Now() somewhere? What is causing the flickering effect here when I hover about the menu-items?
<cc1:MenuBuilder ID="Mainmenu" MenuName="Mainmenu" runat="server" CssClass="menubar-nav-list" UseDiv="true" ShowLevels="1" />
<script language="javascript" type="text/javascript">
Cufon.replace('#Mainmenu .menuitem', { fontFamily: 'DIN Eng', hover: true });
</script>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您必须在
标记之后执行以下代码。
然后致电
或干脆
The Cufon.now 就可以解决问题。有关更多信息,请阅读文档。在本文档中,他们说在
之前使用它,但我们发现这并不能解决所有闪烁问题,而是在
之后使用它做。
You have to execute the following code right after the
<body>
tag.And then call
or simply
The Cufon.now is doing the trick. For more information read the documentation. In this documentation they say to use it before the
</body>
but we found that this doesn't fix all the flickering problems but right after the<body>
does.我没有发现你的代码有任何问题,所以这只是一个盲目的尝试。
要使用像 #Mainmenu .menuitem 这样的 DOM 选择方法(而不仅仅是 h1 或 h2),Cufon 需要像 jQuery 这样的 javascript 库。
是否有可能 jQuery 没有在正确的时间加载,或者您已将 IE 设置为无缓存模式,迫使它在每次重新加载页面时重新下载 jQuery?
I don't see anything wrong with your code, so this is just a shot in the dark.
To use DOM selection methods like #Mainmenu .menuitem (instead of just h1 or h2), Cufon requires a javascript library like jQuery.
Is it possible that jQuery isn't loading at the right time, or that you've set IE to no-cache mode, forcing it to redownload jQuery every time you reload the page?