繁体   English   中英

jQuery Click事件不适用于IE中的Fancybox调用

[英]jQuery Click event not working with Fancybox call in IE

好的,这是一个很大的问题。 我正在构建的网站依赖于Fancybox,而且它必须与IE兼容。...我只是了解到,当单击一个启动fancybox的div(在Safari和Firefox中)时,它不会出现在IE 7(IE)中8 似乎正在工作)。 我的脚本如下所示:

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>

如果有关系,我将使用一些特定于IE的CSS称为border-radius hack:

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

border-radius.htc文件可位于此处 如果有问题,我正在使用jQuery 1.5.1和Fancybox 1.3.4。

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

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

如果是这样,可以使用有效的DocType阻止IE在Quirks模式下打开。 尝试将其添加到html文档的顶部:

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

希望有效!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM