开发者

doesnt work in IE

here is my javasript:

            function random_imglink() {
            var myimages = [
                {image: "/documents/templates/projedepo/banner/canon.jpg", url: "/index.cfm?fuseaction=objects2.detail_product&product_id=612&stock_id=612"},
                {image: "/documents/templates/projedepo/banner/indigovision.jpg", url: "http://www.url2.com"}
            ];

            var ry=Math.floor(Math.random()*myimages.length);

            var randomImage = myimages[ry];

            var randomImageLink = '<a id="random_link" href="' + randomImage.url + '"><img style="z-index:1;position:absolute; left:70px; top:360px;开发者_运维百科" border="0" align="absmiddle" src="/documents/templates/projedepo/banner/daha_fazlasi.jpg" /></a><img id="random_img" src="'+randomImage.image+'" height="420" width="964" />';
            document.getElementById("image2").innerHTML = randomImageLink;
            }
 $(function() {
  $(".image2").click(function() {
  var image = $(this).attr("rel");
    var rel = $('#random_img').hide().fadeIn('slow').attr('src');
    $('#random_img').attr('src', image);

  var randomLink = $(this).attr("href");
  $('#random_link').attr('href',randomLink);

    var image2 = $('#random_img').attr('src');
    $("#thumb2 a img").removeClass("open");
    $("#thumb2 a[rel='" + image2 + "'] img").addClass("open");
    return false;
  });
 }); 

 $(document).ready(function() {
   var image2 = $('#random_img').attr('src');
   $("#thumb2 a[rel='" + image2 + "'] img").addClass("open");
 });
                random_imglink()

Here is my html:

<div id="slider_container">    
<div id="image2">Here is written my sript</div>
<div id="thumb2">

<a href="/index.cfm?fuseaction=objects2.detail_product&product_id=612&stock_id=612" rel="/documents/templates/projedepo/banner/canon.jpg" class="image2" ><img title="Canon" class="slider_thumb" src="/documents/templates/bilgiteknolojileri/images/t_flash/t1.png" border="0"/></a>
<a href="http://www.url2.com" rel="/documents/templates/projedepo/banner/indigovision.jpg" class="image2"><img title="IndigoVision" class="slider_thumb" src="/documents/templates/bilgiteknolojileri/images/t_flash/t2.png" border="0"/></a>

</div></div>

IN Internet Explorer, NOT in Firefox or Opera, at first it works fine, the random image is displayed and thumbnails are ok, but when i click the thumbnail, the random image turns in frame with overflows, like this: http://vteam.net.ru/_fr/11/1923928.jpg


The only suspect thing I see is this:

$(document).ready(function() {
   var image2 = $('#random_img').attr('src');
   $("#thumb2 a[rel='" + image2 + "'] img").addClass("open");
 });
                random_imglink()

In your HTML-source you wrote

    <div id="image2">Here is written my sript</div>

...so I assume that the script is placed there. This can be a problem.Replace the code above with

$(document).ready(function() {
       var image2 = $('#random_img').attr('src');
       $("#thumb2 a[rel='" + image2 + "'] img").addClass("open");
       random_imglink();
     });

(Move the call of random_imglink() into the ready-function). Otherwise it's called immediately, but there will be an element manipulated (#image2) which is not closed yet, what may result in an error in MSIE.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜