Home >Web Front-end >JS Tutorial >The Swiper control cannot accurately locate the specified page under IE9
Use the carousel control to display the image files in the table. When the image file in the table is clicked, use the carousel control (Swiper) to display the specified image, and at the same time , you can turn pages left and right and browse all pictures forward and backward.
(1) Use JS to create the torso of Swiper (Swiper is equivalent to the soul, and the soul must be attached to the body to function).
__createPreviewHtml: function(){ if($('#__sc1').length>0) return; var html = '<p id="__sc1" class="swiper-container" style="z-index:9999;">' + ' <a href="javascript:void(0);" id="__sc_closeBtn" class="closeBtn" title="close"> X </a>' + ' <p class="swiper-wrapper"> ' + '</p> ' + '<p class="swiper-pagination"></p>' + '<p class="swiper-button-prev"></p>' + '<p class="swiper-button-next"></p>' + '</p>'; $(document.body).append(html); $('#__sc_closeBtn').on('click',this.__hidePreviewBox); }
(2) Traverse the image files in the table and insert them into Swiper's torso to obtain the index number (index) and URL of the clicked image file (uniquely identified by the file ID).
var index = 0; var i = 0; me._grid.findRow(function(row){ var fileId2 = row.fileId; var fileName2 = row.fileName.toLowerCase(); if(fileName2 && imgReg.test(fileName2)==true){ if(fileId == fileId2){ index = i; } var picParam = me.fileService + "/preview?fileId=" + encodeURIComponent(fileId2); var imgHtml = '<img src="' + picParam + '"/>'; var $slide = $('<p class="swiper-slide">' + imgHtml + '</p>'); $('.swiper-wrapper').append($slide); i++; } }); if(typeof(mySwiper) != 'undefined'){ mySwiper.removeAllSlides(); }
(3) Create a Swiper control, and use Swiper's slideTo(index) method to locate the specified position and display the picture.
//$('.swiper-pagination span').eq(index).trigger('click'); });
The above is the detailed content of The Swiper control cannot accurately locate the specified page under IE9. For more information, please follow other related articles on the PHP Chinese website!