幻灯片图像与按钮

时间:2014-06-17 16:19:00

标签: javascript jquery html css internet-explorer

我正在为我的公司管理一个由其他人制作的网站(24,000美元),我们编辑了幻灯片,其底部带有按钮的图像导航到相应的照片。我们所做的是在幻灯片中添加带有链接和按钮的图像。问题是它在铬中工作正常但在I.E中没有。在I.E.按钮在那里,但最后一个按钮只给出一个空白图像(我们添加的图像进入第一个按钮)。它还在第一个(添加的)图像周围给出了一个奇怪的边框。这是HTML。新的第一张图片有一个链接,而其他图片没有。我查看了javascript和jquery,它似乎没有规定允许有多少图像/按钮或任何东西。对于长代码感到抱歉,我感谢您花时间阅读它。

<a href="http:\\www.supplysourceoutlet.com" target="_blank"> <img src="/images/home-slideshow/photo-outlet.jpg" alt="" width="684" height="325"></a>

<img src="/images/home-slideshow/photo-01.jpg" alt="" width="684" height="325">
 <img src="/images/home-slideshow/photo-02.jpg" alt="" width="684" height="325">
 <img src="/images/home-slideshow/photo-03.jpg" alt="" width="684" height="325">
 <img src="/images/home-slideshow/photo-04.jpg" alt="" width="684" height="325">
 <img src="/images/home-slideshow/photo-05.jpg" alt="" width="684" height="325">

            </div>
        </div>
        <div class="paging">
            <a href="#" rel="1">&nbsp;</a>
            <a href="#" rel="2">&nbsp;</a>
            <a href="#" rel="3">&nbsp;</a>
            <a href="#" rel="4">&nbsp;</a>
            <a href="#" rel="5">&nbsp;</a>
            <a href="#" rel="6">&nbsp;</a>'

以下是幻灯片演示的javascript:

$(document).ready(function() {
//Show the paging and activate its first link
$(".paging").show();
$(".paging a:first").addClass("active");

//Get size of the image, how many images there are, then determine the size of the image reel.
var imageWidth = $(".window").width();
var imageSum = $(".image_reel img").size();
var imageReelWidth = imageWidth * imageSum;

//Adjust the image reel to its new size
$(".image_reel").css({'width' : imageReelWidth});

//Paging  and Slider Function
rotate = function(){
    var triggerID = $active.attr("rel") - 1; //Get number of times to slide
    var image_reelPosition = triggerID * imageWidth; //Determines the distance the image reel needs to slide

    $(".paging a").removeClass('active'); //Remove all active class
    $active.addClass('active'); //Add active class (the $active is declared in the rotateSwitch function)

    //Slider Animation
    $(".image_reel").animate({
        left: -image_reelPosition
    }, 500 );

}; 

//Rotation  and Timing Event
rotateSwitch = function(){
    play = setInterval(function(){ //Set timer - this will repeat itself every 7 seconds
        $active = $('.paging a.active').next(); //Move to the next paging
        if ( $active.length === 0) { //If paging reaches the end...
            $active = $('.paging a:first'); //go back to first
        }
        rotate(); //Trigger the paging and slider function
    }, 7000); //Timer speed in milliseconds (7 seconds)
};

rotateSwitch(); //Run function on launch

//On Hover
$(".image_reel a").hover(function() {
    clearInterval(play); //Stop the rotation
}, function() {
    rotateSwitch(); //Resume rotation timer
}); 

//On Click
$(".paging a").click(function() {
    $active = $(this); //Activate the clicked paging
    //Reset Timer
    clearInterval(play); //Stop the rotation
    rotate(); //Trigger rotation immediately
    rotateSwitch(); // Resume rotation timer
    return false; //Prevent browser jump to link anchor
});

});

1 个答案:

答案 0 :(得分:0)

边框的原因以及只有第一个(添加的)一个链接是因为它是唯一一个带有标记的链接。你可以在img标签上添加一个border =“0”来摆脱这样的边框:

<a href="http:\\www.supplysourceoutlet.com" target="_blank">
  <img src="/images/home-slideshow/photo-outlet.jpg" alt="" border="0" width="684" height="325">
</a>

要修复另一部分我需要知道image_reel类所在的div在哪里可以发布更多的html?