2011-03-21 24 views
1

好吧,这是一个巨大的问题。我正在建设的网站依赖于Fancybox,并且它必须是IE兼容....我只是开始学习,当点击启动fancybox(safari和firefox)的div时,它不会出现在IE 7(IE 8 似乎工作)。我的脚本是这样的:jQuery Click事件不能在IE中使用Fancybox调用

jQuery(document).ready(function() { 
    $(".students_button").click(function(){ 
     $.fancybox(
      '<p>HTML content here</p>', 
      { 
       'autoDimensions' : false, 
       'width'    : 600, 
       'height'   : 'auto', 
       'transitionIn'  : 'fade', 
       'transitionOut'  : 'fade' 
      } 
     ); 
    }); 
}); 

我对按钮CSS显示为这样:

#content #home #buttons { 
    width: 310px; 
    float: left; 
    margin-right: 10px; 
    margin-right: 0; 
} 
#content #home #buttons #button { 
    display: block; 
    height: 70px; 
    border-radius: 15px; 
    -moz-border-radius: 15px; 
    -webkit-border-radius: 15px; 
    background: #3a79f7 url(/images/blue_button_bg.png) repeat-x; 
    filter: e("progid:DXImageTransform.Microsoft.gradient(startColorstr='#3d7cfa', endColorstr='#2463e1')"); 
    background: -webkit-gradient(linear, left top, left bottom, from(#3d7cfa), to(#2463e1)); 
    background: -moz-linear-gradient(top, #3d7cfa, #2463e1); 
    pointer: hand; 
    margin-bottom: 10px; 
} 
#content #home #buttons #button #text { 
    color: #ffffff; 
    font-size: 22pt; 
    text-align: center; 
    position: relative; 
    top: 13px; 
    z-index: 1000; 
} 

最后,我的HTML是这样的:

<div id="content"> 
    <div id="home"> 
    <div id="buttons"> 
     <div id="button"> 
      <div id="text" class="students_button">Students</div> 
     </div> 
    </div> 
    </div> 
</div> 

如果它的事项,我m使用一些特定于IE的CSS来调用边界半径攻击:

#content { 
    #home { 
     #buttons { 
      #button { 
       behavior: url(/border-radius.htc); 
      } 
     } 
    } 
} 

border-radius.htc文件可以位于here。如果它很重要,我正在使用jQuery 1.5.1和Fancybox 1.3.4。

非常感谢您为解决此问题提供的任何帮助!

回答

1

我复制并粘贴了您的代码,并且它在IE7和IE8中按预期工作。但是,当IE处于Quirks模式时,它不起作用。是否有可能IE浏览器加载页面的怪癖模式?如果您不知道,可以通过按F12打开IE开发者工具并查看文档模式字段找到。

如果这是问题,您可以通过使用有效的DocType阻止IE以Quirks模式打开。尝试添加到您的HTML文件的顶部:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 

希望工程!

+0

*啪啪啪*哼!我使用的不是IE 7支持的HTML 5文档类型!任何想法用HTML 5文档来解决这个问题? – 2011-03-21 17:59:57

+0

在stackoverflow上有类似的问题,但目前没有答案被标记为答案.http://stackoverflow.com/questions/5036315/standards-mode-in-ie7-with-html5 – 2011-03-21 18:20:23