簡體   English   中英

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

[英]Jquery .load img not working in firefox and IE!

我的網站上有這個 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}

請幫忙。

您的 javascript 中的代碼和平(我認為)不是 javascript,也許是 Smarty 標簽? 螢火蟲控制台在那里啟動一個錯誤。

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM