Cufon 使用 jQuery 切换 css 可见性仅在 IE8 中失败
我正在使用 jQuery 和 cufon 字体替换。它工作得很好,但是,我正在编写脚本来消除较慢连接上的 FOUC(无样式内容的闪存)问题。
为此,我使用 css 将 cufon 替换元素的可见性切换为“隐藏”,然后在文档末尾,我调用 jQuery 以重新打开可见性。
这在我测试过的所有浏览器中都表现良好,除了 IE8。
您知道什么会导致 IE8 使用此脚本出现问题吗?
<script src="mythemelocation/js/cufon-yui.js" type="text/javascript"></script>
<script src="wp-content/plugins/fonts/Delicious_500-Delicious_700-Delicious_italic_500-Delicious_italic_700.font.js" type="text/javascript"></script>
<script src="wp-content/plugins/fonts/League_Gothic_400.font.js" type="text/javascript"></script>
<script src="wp-content/plugins/fonts/Vegur_400-Vegur_700.font.js" type="text/javascript"></script>
<script type="text/javascript">Cufon.set('fontFamily', 'League Gothic').replace('h1')('h2')('h4')('.siteTitle')('.tagline');</script>
<script type="text/javascript"> Cufon.now(); </script>
<script type='text/javascript'>jQuery(document).ready(function(){jQuery('#accordion-1, .siteTitle,.posttitle,.tagline,h4').css('visibility', 'visible');});</script>
</body>
I'm using jQuery along with cufon font replacement. Its been working great, however, I'm working on script to eliminate the FOUC (flash of unstyled content) issue on slower connections.
To do this, I'm using css to toggle the visibility of the cufon replacement elements to "hidden", then at the end of the document, I have a call to jQuery to toggle visibility back on.
This works great in all browsers I've tested against, except IE8
Any ideas what would cause IE8 to have problems with this script?
<script src="mythemelocation/js/cufon-yui.js" type="text/javascript"></script>
<script src="wp-content/plugins/fonts/Delicious_500-Delicious_700-Delicious_italic_500-Delicious_italic_700.font.js" type="text/javascript"></script>
<script src="wp-content/plugins/fonts/League_Gothic_400.font.js" type="text/javascript"></script>
<script src="wp-content/plugins/fonts/Vegur_400-Vegur_700.font.js" type="text/javascript"></script>
<script type="text/javascript">Cufon.set('fontFamily', 'League Gothic').replace('h1')('h2')('h4')('.siteTitle')('.tagline');</script>
<script type="text/javascript"> Cufon.now(); </script>
<script type='text/javascript'>jQuery(document).ready(function(){jQuery('#accordion-1, .siteTitle,.posttitle,.tagline,h4').css('visibility', 'visible');});</script>
</body>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用
.show()
而不是.css('visibility', 'visible')
。因此您的脚本将如下所示:
另外,您不需要为内联脚本编写 3 个
元素。
Use
.show()
instead of.css('visibility', 'visible')
.So your script would look like this:
Also you don't need to write 3
<script>
elements for your inline scripts.