Internet Explorer JavaScript-换行符崩溃脚本
我在JavaScript中有一个onclick事件,我选择如下格式:Internet Explorer JavaScript-换行符崩溃脚本,javascript,html,internet-explorer,firefox,Javascript,Html,Internet Explorer,Firefox,我在JavaScript中有一个onclick事件,我选择如下格式: <a href="" onclick = " $('.white_content').html('<img src=\'/making.gif\'>'); $.ajax({ url: '/show_album.php?id=<?=$album['id']?>', type: 'GET', s
<a href="" onclick = "
$('.white_content').html('<img src=\'/making.gif\'>');
$.ajax({
url: '/show_album.php?id=<?=$album['id']?>',
type: 'GET',
success: function(data){
$('.white_content').html(data);
},
error: function(){
alert('failed');
}
});
return false;">
改为执行以下操作:
<script>
function myOnclick() {
$('.white_content').html('<img src=\'/making.gif\'>');
$.ajax({
url: '/show_album.php?id=<?=$album['id']?>',
type: 'GET',
success: function(data){
$('.white_content').html(data);
},
error: function(){
alert('failed');
}
});
return false;
}
</script>
<a href="" onclick="return myOnclick();">
函数myOnclick(){
$('.white_content').html('');
$.ajax({
url:“/show_album.php?id=”,
键入:“GET”,
成功:功能(数据){
$('.white_content').html(数据);
},
错误:函数(){
警报(“失败”);
}
});
返回false;
}
有什么特别的原因需要这么多JS内联的吗?如果您将其移出,您将省去很多麻烦,特别是因为您似乎已经在使用jQuery了。。