<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script src="jquery-1.3.2.min.js"></script>
<script language="javascript">
var _layout=[{i:'m101',c:'c1',t:'t1'},{i:'m102',c:'c2',t:'t1'},{i:'m103',c:'c3',t:'t1'},];function ea(l){
$.each(l.reverse(),function(i){
document.write(l[i].i);
})
}$(function(){
ea(eval(_layout))
})
</script>
</head><body>
</body>
</html>
在火狐中就能运行出结果,但是在IE中就报错,这是为什么?
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script src="jquery-1.3.2.min.js"></script>
<script language="javascript">
var _layout=[{i:'m101',c:'c1',t:'t1'},{i:'m102',c:'c2',t:'t1'},{i:'m103',c:'c3',t:'t1'},];function ea(l){
$.each(l.reverse(),function(i){
document.write(l[i].i);
})
}$(function(){
ea(eval(_layout))
})
</script>
</head><body>
</body>
</html>
在火狐中就能运行出结果,但是在IE中就报错,这是为什么?
var _layout=[{i:'m101',c:'c1',t:'t1'},{i:'m102',c:'c2',t:'t1'},{i:'m103',c:'c3',t:'t1'}]; {
//对象属性 最后一个没有 ,号
}
除了这个问题外为什么还要使用eval序列化呢? _layout本身就是对象了。