1

I have a bit of a problem with my shadowbox, it works fine in FF, but it refuses to work in IE 7 or 8.

I am using these scripts,

<script type="text/javascript" src="scripts/jquery-1.4.2.js"</script>
<link rel="stylesheet" type="text/css" href="scripts/shadowbox/shadowbox.css">
<script type="text/javascript" src="scripts/shadowbox/shadowbox.js"></script>
<script type="text/javascript">
Shadowbox.init();
</script>

and I am also using this jQuery to assign the rel attribute to all the a tags inside of my calendar, and it works fine in FF, but not at all in IE.

$(function() {
   $('#wp-calendar').find('a').each( function() {
       $(this).attr( 'rel', 'shadowbox[Mixed];width=520;height=390');
   });
});

but for some reason it just refuses to work in any IE.

I really am at the end of my rope here, any help would be appreciated, thanx!

4

1 回答 1

2

Shadowbox.init();在页面加载时立即调用,但rel仅在 jquery dom:ready 状态上添加参数。

当方法执行时,Shadowbox 只能拾取已经有rel=...参数的链接。init()

在某些浏览器中显然首先发生dom:ready事件,然后执行脚本<script>,但在 IE 中不执行。分配 rel 属性后,您应该Shadowbox.init()在 jquery 内部移动:$(function ...

$(function() {
   $('#wp-calendar').find('a').each( function() {
       $(this).attr( 'rel', 'shadowbox[Mixed];width=520;height=390');
   });
   Shadowbox.init();
});
于 2010-05-06T09:25:35.633 回答