2012-07-21 59 views
0

我有一個父母的html頁面,其中包括我的垂直菜單中的accordian JS文件。此外,我想包括一個簡單的圖像幻燈片放映,其中的JS文件。爲了通過包含兩個JS文件來避免jQuery衝突。我已經使用了我的<frame>標籤。它的作品在所有現代瀏覽器中都很好。但在Internet Explorer 6中,我的圖像幻燈片根本不起作用。 這是我的代碼。jquery在使用iframe時的衝突

<link type="text/css" rel="stylesheet" href="css/template.css"> 
<script type="text/javascript" language="javascript" src="js/jquery.js"></script> 

<script type="text/javascript"> 
$(document).ready(function() 
{ 
    //slides the element with class "menu_body" when paragraph with class "menu_head" is clicked 
    $("#firstpane p.menu_head").click(function() 
    { 
     $(this).css({backgroundImage:"url()"}).next("div.menu_body").slideToggle(300).siblings("div.menu_body").slideUp("slow"); 
     $(this).siblings().css({backgroundImage:"url()"}); 
    }); 

}); 
</script> 

<style type="text/css"> 

} 
.menu_list {  
    width:100% 
} 
.menu_head { 
    padding: 0px 10px; 
    cursor: pointer; 
    position: relative; 
    margin:1px; 
    font-weight:bold; 
    background: #fff url(left.png) center right no-repeat; 
} 
.menu_body { 
    display:none; 

} 
.menu_body p{ 
    display:block; 
    background-color:#fff; 
    margin-top:0px; 
    padding-left:10px; 
    text-decoration:none; 
} 
.menu_body a:hover{ 
    color: #000000; 
    text-decoration:underline; 
    } 
</style> 
</head> 
<body> 
<table border="1" width="100%" cellspacing="0" cellpadding="0"> 
       <tr > 
        <td ><iframe src="simple_gallery.html" width="300px" height="250px" marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="0" scrolling="No"></iframe></td> 
       </tr> 
       </table> 
       <div id="firstpane" class="menu_list"> <!--Code for menu starts here--> 
     <p class="menu_head">Header-1</p> 
     <div class="menu_body"> 
     <a href="#">Link-1</a> 
     <a href="#">Link-2</a> 
     <a href="#">Link-3</a> 
     </div> 
     <p class="menu_head">Header-2</p> 
     <div class="menu_body"> 
      <a href="#">Link-1</a> 
     <a href="#">Link-2</a> 
     <a href="#">Link-3</a> 
     </div> 
     <p class="menu_head">Header-3</p> 
     <div class="menu_body"> 
      <a href="#">Link-1</a> 
     <a href="#">Link-2</a> 
     <a href="#">Link-3</a>   
     </div> 
    </div> 

iframe的鏈接頁面內容:

<link rel="stylesheet" type="text/css" href="css/simple_slider.css" /> 
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.0/jquery.min.js"></script> 
<script type="text/javascript" src="JS/simplegallery.js"></script> 
<script type="text/javascript"> 
var mygallery=new simpleGallery({ 
    wrapperid: "simplegallery1", //ID of main gallery container, 
    dimensions: [300,250], //width/height of gallery in pixels. Should reflect dimensions of the images exactly 
    imagearray: [ 
     ["images/img-2.jpg", "#", "_new", "There's nothing like a nice swim in the Summer."], 
     ["images/img-1.jpg", "#", "", ""], 
     ["images/r-tata.jpg", "", "", "Eat your fruits, it's good for you!"], 
     ["images/inside-image1.jpg", "", "", ""] 
    ], 
    autoplay: [true, 2500, 5], //[auto_play_boolean, delay_btw_slide_millisec, cycles_before_stopping_int] 
    persist: false, //remember last viewed slide and recall within same session? 
    fadeduration: 500, //transition duration (milliseconds) 
    oninit:function(){ //event that fires when gallery has initialized/ ready to run 
     //Keyword "this": references current gallery instance (ie: try this.navigate("play/pause")) 
    }, 
    onslide:function(curslide, i){ //event that fires after each slide is shown 
     //Keyword "this": references current gallery instance 
     //curslide: returns DOM reference to current slide's DIV (ie: try alert(curslide.innerHTML) 
     //i: integer reflecting current image within collection being shown (0=1st image, 1=2nd etc) 
    } 
}) 
</script> 
<style type="text/css"> 

} 
.menu_list {  
    width:100% 
} 
.menu_head { 
    padding: 0px 10px; 
    cursor: pointer; 
    position: relative; 
    margin:1px; 
    font-weight:bold; 
    background: #fff url(left.png) center right no-repeat; 
} 
.menu_body { 
    display:none; 

} 
.menu_body p{ 
    display:block; 
    background-color:#fff; 
    margin-top:0px; 
    padding-left:10px; 
    text-decoration:none; 
} 
.menu_body a:hover{ 
    color: #000000; 
    text-decoration:underline; 
    } 
</style> 
<div id="simplegallery1"></div>  
+0

您是否測試過以檢查您的幻燈片插件是否與IE6兼容? – 2012-07-21 11:21:26

+0

@FabrícioMatté我檢查了它是在IE 6中輕鬆工作。 – 2012-07-21 11:22:16

+0

@FabrícioMatté在我使用它之前我的代碼我檢查了兩個jQuery的IE 6兼容性。 – 2012-07-21 11:24:00

回答

1

而不是使用一個iFrame來阻止一個jQuery衝突你就不能使用noConflict使用jQuery的?看看documentation

+0

你認爲我會解決問題...... ?? ...並且IE 6會支持這個jquery noconflict完美..... ?? – 2012-07-21 11:28:59

+0

是IE6支持noconflict方法。但IE6現在佔目標市場的0.2%,擁有最新的瀏覽器統計數據,我有點希望很多網站都支持IE6支持,所以我們不再需要繼續與他們合作,並且讓人們升級:) – 2012-07-21 11:30:18