0
警報警報(document.inform.cid);即將爲未定義當我嘗試訪問javascript數組時,正在填充未定義的值
<html>
<head>
<script type="text/javascript">
var interval = window.setInterval(iterate, 5000);
function iterate() {
var myStringArray = ["user1", "user2"];
iterate.arr = iterate.arr || myStringArray.slice(0);
//if it still has elements left
if(iterate.arr.length > 0) {
document.inform.cid = iterate.arr.pop(); //remove the top one
alert(document.inform.cid);
document.inform.pwd = "xxxxxxxx";
document.inform.target = iterate.arr.length; // a different target each time - length of the arr
document.inform.submit();
} else {
window.clearInterval(interval); //no more left cancel it
}
};
</script>
</head>
<body >
<form name="inform" target="newWin" action="https://www.google.co.in/">
<input type="hidden" name="throttle" value="999" />
<input type="text" name="cid" />
<input type="text" name="pw" />
<input type="submit" value="go" onclick="iterate()">
</form>
</body>
</html>
忘記'.value'在你的JavaScript的所有節點。 –