Javascript 加载在firefox和IE中不工作的img!
我在我的网站上有这个javascript,它可以在点击时加载图像,但在Firefox或IE中不能加载Javascript 加载在firefox和IE中不工作的img!,javascript,jquery,Javascript,Jquery,我在我的网站上有这个javascript,它可以在点击时加载图像,但在Firefox或IE中不能加载 <script type="text/javascript"> $(document).ready(function(){ $("#photo1").click(function(){ var img = new Image(); $(i
<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>
$(文档).ready(函数(){
$(“#photo1”)。单击(函数(){
var img=新图像();
$(img).加载(函数(){
$(“#大图像”).hide();
$('big image').attr('src','{/literal}{$purl}/t/{$p.p1}?{$smarty.now}{literal}');
$(“#大图像”).fadeIn();
}).错误(函数(){
}).attr('src','{/literal}{$purl}/t/{$p.p1}?{$smarty.now}{literal}');
});
{/literal}
{如果$p.p2 ne”“}
{literal}
$(“#photo2”)。单击(函数(){
var img=新图像();
$(img).加载(函数(){
$(“#大图像”).hide();
$('big image').attr('src','{/literal}{$purl}/t/{$p.p2}?{$smarty.now}{literal}');
$(“#大图像”).fadeIn();
}).错误(函数(){
}).attr('src','{/literal}{$purl}/t/{$p.p2}?{$smarty.now}{literal}');
});
{/literal}
{/if}
{如果$p.p2 ne”“}
{literal}
$(“#photo3”)。单击(函数(){
var img=新图像();
$(img).加载(函数(){
$(“#大图像”).hide();
$('big image').attr('src','{/literal}{$purl}/t/{$p.p3}?{$smarty.now}{literal}');
$(“#大图像”).fadeIn();
}).错误(函数(){
}).attr('src','{/literal}{$purl}/t/{$p.p3}?{$smarty.now}{literal}');
});
{/literal}
{/if}
{literal}
});
$(文档).ready(函数(){
$('.gig desc').linkify();
$(“.gig描述a”)。每个(函数(){
$(this.attr(“target”,_blank”);
});
});
这是图像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}
{if$p.p2 ne”“}{/if}
{if$p.p3 ne”“}{/if}
请提供帮助。您的javascript中有很多代码(我认为)不是javascript,可能是Smarty标记?t firebug控制台在此启动一个错误
{/literal}
{if $p.p2 ne ""}
{literal}
你检查过FireFox的错误控制台了吗。可能有/曾经有一条有用的错误消息?请显示浏览器中的代码,而不是smarty模板中的代码