2011-03-21 27 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