Jquery .load图像无法在Firefox和IE中运行!

时间:2011-06-29 10:41:58

标签: javascript jquery

我在我的网站上有这个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>

这是图像div标签:

<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}

请帮忙。

1 个答案:

答案 0 :(得分:1)

你的javascript中有一些代码(我认为)不是javascript,也许是Smarty标签? firebug控制台在那里发起错误。

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