2012-07-21 58 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