IE 中的 JQuery 选项卡不显示图片

发布于 2024-10-30 16:37:35 字数 3881 浏览 5 评论 0原文

我遇到的问题是我的图片不会显示在 IE8 及更低版本的动态 JQuery 选项卡中,但它们会显示在其他所有浏览器中。我相信它与使用 JQuery 加载选项卡的方式有关,因为当我不加载代码时图片显示得很好。我使用 JQuery .hide() 和 fadeIn() 函数来更改选项卡。

这是我正在谈论的内容的屏幕截图: http://www.marinicorp.net/jquerytabs.htm

以下是网页本身的链接:http://www.marinicorp.net/services .aspx

如果您需要更多信息,请告诉我。

jQuery:

$(document).ready(function () {
$(".tab_content").hide(); //Hide all content
$("ul.tabs li:first").addClass("selected").show(); //Activate first tab
$(".tab_content:first").show(); //Show first tab content

//On Click Event
$("ul.tabNavigation li").click(function () {

    $("ul.tabNavigation li").removeClass("selected"); //Remove any "active" class
    $(this).addClass("selected"); //Add "active" class to selected tab
    $(".tab_content").hide(); //Hide all tab content

    var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
    $(activeTab).fadeIn(); //Fade in the active ID content
    return false;
});

});

HTML:

<div id="tabs" class="tabs">
    <ul class="tabNavigation">
        <li><a href="#tabCon">Construction Services</a></li>
        <li><a href="#tabLand">Landscaping Services</a></li>
        <li><a href="#tabSnow">Plowing Services</a></li>
    </ul>
    <div id="tabCon" class="tab_content">
         <table style="position: absolute; top:35px; left:40px;">
       <tr>
       <td><img class="tables" src="Images/pipeLay.gif" /></td>
       <td><img class="tables" src="Images/projMan.gif" /></td>
       <td><img class="tables" src="Images/surveyeng.gif" /></td>
       </tr>
       </table>  
    </div>
    <div id="tabLand" class="tab_content">
<table style=" position: absolute; left:40px; top:35px;"> <tr>
       <td ><img class="tables" src="Images/playGrounds.gif" /></td>
       <td><img class="tables" src="Images/plantTrees.gif" /></td>
       <td><img class="tables" src="Images/genLand.gif" /></td>
       </tr>
       </table>               
    </div>
    <div id="tabSnow" class="tab_content">
      <table style=" position: absolute; left:40px; top:35px;">
       <tr>
       <td><img class="tables" src="Images/snowplow.gif" /></td>
       <td><img class="tables" src="Images/shovelers.gif" /></td>
       <td><img class="tables" src="Images/bobcat.gif" /></td>
       </tr>
       </table>     
    </div>
</div>

CSS:

.tab_content {padding: 19px 0 22px 16px}
#tabs{top:380px;left:-10px;position: absolute; z-index:3;}
#tabs .tables{margin: 0px 13px 0px 13px;padding: 0px;border: 2px outset #999999;z-     index:-1;}
UL.tabNavigation{list-style: none; margin: 0;padding: 0;}
UL.tabNavigation LI{display: inline;}
UL.tabNavigation LI A{padding: 10px 20px 10px 20px;background-color: #C0C0C0;text decoration: none;font-size: 12pt;color: #000000;font-family: Tahoma;}
UL.tabNavigation LI A.selected, UL.tabNavigation LI A:hover{border width:0px;background-color: #C0C0C0;padding: 10px 20px 13px 20px;color: #FFFFFF;font-size: 12pt;}        
UL.tabNavigation LI A:focus {outline: 0;}
div.tabs > div{padding: 5px;margin-top: 11px;width: 620px;height: 330px;}               
div.tabs > div h2 {margin-top: 0;}
#tabCon{background-color: #C0C0C0;}
#tabLand{background-color: #C0C0C0;}
#tabSnow{background-color: #C0C0C0;}
.waste {min-height: 1000px;}

The problem I am having is that my pictures do not show up in the dynamic JQuery tabs in IE8 and below, but they show up in every other browser. I believe that it is associated with how the tabs load using JQuery because the pictures show up fine when I do not load the code. I used JQuery .hide() and fadeIn() functions in order to change tabs.

Here is a screen shot of what I am talking about: http://www.marinicorp.net/jquerytabs.htm

Here is a link to the web page itself: http://www.marinicorp.net/services.aspx

If you need anymore information just let me know.

JQuery:

$(document).ready(function () {
$(".tab_content").hide(); //Hide all content
$("ul.tabs li:first").addClass("selected").show(); //Activate first tab
$(".tab_content:first").show(); //Show first tab content

//On Click Event
$("ul.tabNavigation li").click(function () {

    $("ul.tabNavigation li").removeClass("selected"); //Remove any "active" class
    $(this).addClass("selected"); //Add "active" class to selected tab
    $(".tab_content").hide(); //Hide all tab content

    var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
    $(activeTab).fadeIn(); //Fade in the active ID content
    return false;
});

});

HTML:

<div id="tabs" class="tabs">
    <ul class="tabNavigation">
        <li><a href="#tabCon">Construction Services</a></li>
        <li><a href="#tabLand">Landscaping Services</a></li>
        <li><a href="#tabSnow">Plowing Services</a></li>
    </ul>
    <div id="tabCon" class="tab_content">
         <table style="position: absolute; top:35px; left:40px;">
       <tr>
       <td><img class="tables" src="Images/pipeLay.gif" /></td>
       <td><img class="tables" src="Images/projMan.gif" /></td>
       <td><img class="tables" src="Images/surveyeng.gif" /></td>
       </tr>
       </table>  
    </div>
    <div id="tabLand" class="tab_content">
<table style=" position: absolute; left:40px; top:35px;"> <tr>
       <td ><img class="tables" src="Images/playGrounds.gif" /></td>
       <td><img class="tables" src="Images/plantTrees.gif" /></td>
       <td><img class="tables" src="Images/genLand.gif" /></td>
       </tr>
       </table>               
    </div>
    <div id="tabSnow" class="tab_content">
      <table style=" position: absolute; left:40px; top:35px;">
       <tr>
       <td><img class="tables" src="Images/snowplow.gif" /></td>
       <td><img class="tables" src="Images/shovelers.gif" /></td>
       <td><img class="tables" src="Images/bobcat.gif" /></td>
       </tr>
       </table>     
    </div>
</div>

CSS:

.tab_content {padding: 19px 0 22px 16px}
#tabs{top:380px;left:-10px;position: absolute; z-index:3;}
#tabs .tables{margin: 0px 13px 0px 13px;padding: 0px;border: 2px outset #999999;z-     index:-1;}
UL.tabNavigation{list-style: none; margin: 0;padding: 0;}
UL.tabNavigation LI{display: inline;}
UL.tabNavigation LI A{padding: 10px 20px 10px 20px;background-color: #C0C0C0;text decoration: none;font-size: 12pt;color: #000000;font-family: Tahoma;}
UL.tabNavigation LI A.selected, UL.tabNavigation LI A:hover{border width:0px;background-color: #C0C0C0;padding: 10px 20px 13px 20px;color: #FFFFFF;font-size: 12pt;}        
UL.tabNavigation LI A:focus {outline: 0;}
div.tabs > div{padding: 5px;margin-top: 11px;width: 620px;height: 330px;}               
div.tabs > div h2 {margin-top: 0;}
#tabCon{background-color: #C0C0C0;}
#tabLand{background-color: #C0C0C0;}
#tabSnow{background-color: #C0C0C0;}
.waste {min-height: 1000px;}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

春夜浅 2024-11-06 16:37:35

今天有一个有趣的事情 - 结果是图像文件本身的编码!尝试使用 fireworks、photoyshop、gimp 或其他工具重新保存图像,看看会发生什么。

(当时很想说不要使用 ie8 ;))

had an interesting one just like this today - turned out it was the encoding of the image files themselves!!! try re-saving the images with fireworks or photyshop or gimp or what ever and see what happens.

(was so tempted to just say don't use ie8 then ;) )

方圜几里 2024-11-06 16:37:35

有一个更好的方法可以做到这一点。使用 JQuery UI 的选项卡。 它可以原生处理常见的缓慢加载场景、浏览器差异和 FOUC 问题带有选项卡式菜单解决方案。

然后,您可以使用 CSS 简单地设置选项卡的样式。它应该更快、更少干扰,并且需要实施的工作也显着减少。

There's a better way to do this. Use JQuery UI's tabs. It natively handles slow-load scenarios, browser discrepancies, and FOUC issues that are common with tabbed menu solutions.

You can then simply style the tabs using CSS. It should be faster and less intrusive, with significantly less work to implement.

木落 2024-11-06 16:37:35

想通了... IE 不会同时加载选项卡中的图像和 div,因此我没有使用 fadein() 函数和每个 div 的 id,而是为每个 div.tab 和选项卡中的图像创建了一个类当 JQuery 调用该类时,它们都会淡出。

这是代码:

HTML:

  <div id="tabs" class="tabs">
    <ul class="tabNavigation">
    <li><a href="#tabLand" name=".tabLand">Landscaping Services</a></li>
    <li><a href="#tabCon" name=".tabCon">Construction Services</a></li>
    <li><a href="#tabSnow" name=".tabSnow">Plowing Services</a></li>
    </ul>

    <div id="tabLand" class="tabLand">
    <table style="position: absolute; left:40px; top:35px;"> 
       <tr>
       <td><img class="tabLand" src="Images/playGrounds.jpg" /></td>
       <td><img class="tabLand" src="Images/plantTrees.jpg" /></td>
       <td><img class="tabLand" src="Images/genLand.jpg" /></td>
       </tr>
       <tr><td></td><td></td></tr>
     </table>               
    </div>
    <div id="tabCon" class="tabCon">
    <table style=" position: absolute; left:40px; top:35px;"> <tr>
       <td ><img class="tabCon" src="Images/pipeLay.jpg" /></td>
       <td><img class="tabCon" src="Images/projMan.jpg" /></td>
       <td><img class="tabCon" src="Images/surveyeng.jpg" /></td>
       </tr>
       <tr><td></td><td></td></tr>
       </table>
    </div>
    <div id="tabSnow" class="tabSnow">
      <table style=" position: absolute; left:40px; top:35px;">
       <tr>
       <td><img class="tabSnow" src="Images/snowplow.jpg" /></td>
       <td><img class="tabSnow" src="Images/shovelers.jpg" /></td>
       <td><img class="tabSnow" src="Images/bobcat.jpg" /></td>
       </tr>
       <tr><td></td><td></td></tr>
       </table>     
    </div>
</div>

JQuery:

$(document).ready(function () {
    var tabArray = new Array();
    tabArray[0] = ".tabCon";
    tabArray[1] = ".tabLand";
    tabArray[2] = ".tabSnow";
    var p = tabArray.length;
    //When page loads...
    for (x = 0; x < p; x++) {
        $(tabArray[x]).hide();
    }

    $("ul.tabNavigation li:first").addClass("selected").show(); //Activate first tab
    var firstTab = $("ul.tabNavigation li:first").find("a").attr("name"); //Show first tab content
    $(firstTab).show();
    //On Click Event
    $("ul.tabNavigation li").click(function () {
        var clearTab = $("ul.tabNavigation li.selected").find("a").attr("name");
        $("ul.tabNavigation li").removeClass("selected"); //Remove any "active" class
        $(clearTab).hide(); //Hide all tab content
        $(this).addClass("selected"); //Add "active" class to selected tab
        var activeTab = $(this).find("a").attr("name"); //Find the href attribute value to identify the active tab + content
        $(activeTab).fadeIn(); //Fade in the active ID content
        return false;
    });
});

Figured it out... IE does not load the images within the tab with the div simultaneously, so instead of using the fadein() function with the id of each div, I created a class for each div.tab and image within the tabs that are all faded in when JQuery calls that class.

Here is the code:

HTML:

  <div id="tabs" class="tabs">
    <ul class="tabNavigation">
    <li><a href="#tabLand" name=".tabLand">Landscaping Services</a></li>
    <li><a href="#tabCon" name=".tabCon">Construction Services</a></li>
    <li><a href="#tabSnow" name=".tabSnow">Plowing Services</a></li>
    </ul>

    <div id="tabLand" class="tabLand">
    <table style="position: absolute; left:40px; top:35px;"> 
       <tr>
       <td><img class="tabLand" src="Images/playGrounds.jpg" /></td>
       <td><img class="tabLand" src="Images/plantTrees.jpg" /></td>
       <td><img class="tabLand" src="Images/genLand.jpg" /></td>
       </tr>
       <tr><td></td><td></td></tr>
     </table>               
    </div>
    <div id="tabCon" class="tabCon">
    <table style=" position: absolute; left:40px; top:35px;"> <tr>
       <td ><img class="tabCon" src="Images/pipeLay.jpg" /></td>
       <td><img class="tabCon" src="Images/projMan.jpg" /></td>
       <td><img class="tabCon" src="Images/surveyeng.jpg" /></td>
       </tr>
       <tr><td></td><td></td></tr>
       </table>
    </div>
    <div id="tabSnow" class="tabSnow">
      <table style=" position: absolute; left:40px; top:35px;">
       <tr>
       <td><img class="tabSnow" src="Images/snowplow.jpg" /></td>
       <td><img class="tabSnow" src="Images/shovelers.jpg" /></td>
       <td><img class="tabSnow" src="Images/bobcat.jpg" /></td>
       </tr>
       <tr><td></td><td></td></tr>
       </table>     
    </div>
</div>

JQuery:

$(document).ready(function () {
    var tabArray = new Array();
    tabArray[0] = ".tabCon";
    tabArray[1] = ".tabLand";
    tabArray[2] = ".tabSnow";
    var p = tabArray.length;
    //When page loads...
    for (x = 0; x < p; x++) {
        $(tabArray[x]).hide();
    }

    $("ul.tabNavigation li:first").addClass("selected").show(); //Activate first tab
    var firstTab = $("ul.tabNavigation li:first").find("a").attr("name"); //Show first tab content
    $(firstTab).show();
    //On Click Event
    $("ul.tabNavigation li").click(function () {
        var clearTab = $("ul.tabNavigation li.selected").find("a").attr("name");
        $("ul.tabNavigation li").removeClass("selected"); //Remove any "active" class
        $(clearTab).hide(); //Hide all tab content
        $(this).addClass("selected"); //Add "active" class to selected tab
        var activeTab = $(this).find("a").attr("name"); //Find the href attribute value to identify the active tab + content
        $(activeTab).fadeIn(); //Fade in the active ID content
        return false;
    });
});
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文