报错信息是 sum is not defined 求帮助
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>对象</title>
<script>
window.onload=function(){
var i=5;
function sum(){
document.getElementsByTagName('span')[0].innerHTML = i;
i--;
if(i==0){
location.assign("https://www.baidu.com");
}
// setTimeout("sum()",1000);
}
// sum();
setInterval("sum()",1000);
}
</script>
</head>
<body>
<h3>操作成功</h3>
<p><span>5</span><span>秒后自动跳转</span><a href="javascript:history.back()">返回</a></p>
<!--
<script>
var i=5;
function sum(){
document.getElementsByTagName('span')[0].innerHTML = i;
i--;
if(i==0){
location.assign("https://www.baidu.com");
}
setTimeout("sum()",1000);
}
sum();
</script>
-->
</body>
</html>