Jquery.load img在firefox和IE中不起作用

Jquery .load img not working in firefox and IE!

本文关键字:IE 不起作用 firefox load img Jquery      更新时间:2023-09-26

我的网站上有这个javascript,它可以很好地在点击时加载图像,但不能在Firefox或IE中分叉!

<script type="text/javascript">
                $(document).ready(function(){
                  $("#photo1").click(function(){
                    var img = new Image();
                    $(img).load(function () {
                        $('#big-image').hide();
                        $('#big-image').attr('src', '{/literal}{$purl}/t/{$p.p1}?{$smarty.now}{literal}');  
                        $('#big-image').fadeIn();
                    }).error(function() {
                    }).attr('src', '{/literal}{$purl}/t/{$p.p1}?{$smarty.now}{literal}');
                  });
                  {/literal}
                  {if $p.p2 ne ""}
                  {literal}
                  $("#photo2").click(function(){
                    var img = new Image();
                    $(img).load(function () {
                        $('#big-image').hide();
                        $('#big-image').attr('src', '{/literal}{$purl}/t/{$p.p2}?{$smarty.now}{literal}');  
                        $('#big-image').fadeIn();
                    }).error(function() {
                    }).attr('src', '{/literal}{$purl}/t/{$p.p2}?{$smarty.now}{literal}');
                  });
                  {/literal}
                  {/if}
                  {if $p.p2 ne ""}
                  {literal}
                  $("#photo3").click(function(){
                    var img = new Image();
                    $(img).load(function () {
                        $('#big-image').hide();
                        $('#big-image').attr('src', '{/literal}{$purl}/t/{$p.p3}?{$smarty.now}{literal}');  
                        $('#big-image').fadeIn();
                    }).error(function() {
                    }).attr('src', '{/literal}{$purl}/t/{$p.p3}?{$smarty.now}{literal}');
                  });
                  {/literal}
                  {/if}
                  {literal}
                });
                $(document).ready( function() {
                 $('.gig-desc').linkify();
                    $(".gig-desc a").each(function() {
                        $(this).attr("target", "_blank");
                    });
                });
                </script>

这里是imagediv标签:

<div id="photo1"><img alt="{$p.gtitle|stripslashes}" src="{$purl}/t2/{$p.p1}?{$smarty.now}" /></div>    
{if $p.p2 ne ""}<div id="photo2"><img alt="{$p.gtitle|stripslashes}" src="{$purl}/t2/{$p.p2}?{$smarty.now}" /></div>{/if}
{if $p.p3 ne ""}<div id="photo3"><img alt="{$p.gtitle|stripslashes}" src="{$purl}/t2/{$p.p3}?{$smarty.now}" /></div>{/if}

请帮忙。

您的javascript中有一些代码(我认为)不是javascript,也许是Smarty标记?firebug控制台在那里启动了一个错误。

{/literal}
{if $p.p2 ne ""}
{literal}