0
我有這個JavaScript在我的網站和它的作品很大,點擊加載圖像,但不是在Firefox或IE分叉!jquery .load img不能在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}
請幫助。
您是否檢查過FireFox的錯誤控制檯。也許有/有一個有用的錯誤信息? – reporter
請顯示您瀏覽器中的代碼,而不是您smarty模板的代碼 – meo