我是 Javascript 和 Java Server Faces 的新手,我遇到了下一个问题。
下面的代码工作正常:
<?xml version="1.0" encoding="UTF-8"?>
<!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"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets">
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<script type="text/javascript">
function initialize()
{
alert("Testing");
}
</script>
</head>
<body onload="initialize()">
<h1 align="center">Sol-Tech</h1><br />
</body>
</html>
但是当我添加一个 FOR 循环时,它不起作用:
<?xml version="1.0" encoding="UTF-8"?>
<!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"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets">
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<script type="text/javascript">
function initialize()
{
for(var i; i<3; i++)
{
alert("Test");
}
}
</script>
</head>
<body onload="initialize()">
<h1 align="center">Sol-Tech</h1><br />
</body>
</html>
有没有人对如何在 javascript 中执行 FOR 循环而不会出错有任何建议?
在此先感谢,伊曼纽尔