簡體   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