R
Roebie
Hi everyone,
I'm having some weird problem with evaluating the continue statement.
Within a for loop I'm trying to evaluate a string (generated somewhere
earlier) which basically has the continue statement in it. IE6 seems to
have major problems with that as it generates an error "Can't have
'continue' outside of loop". Does anyone know why and/or have a
workaround? I haven't tried any other browser since this one is the
only one available (company policy).
I have included some code to reproduce this behaviour. The first and
second if statements of the testeval function behave as expected. The
third one however produces the mentionned error.
Thanks in advance for any help.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Test Page</title>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html;
charset=ISO-8859-1" />
<style>
div {border:1px solid red;margin-top:2px;}
</style>
<script language="JavaScript" type="text/javascript">
function testeval() {
for (var x=0; x< 6; x++) {
document.getElementById("div" + x).innerHTML = " ";
if (x == 2) continue;
if (x == 4) eval("alert('next line will produce an error')");
if (x == 4) eval("continue");
document.getElementById("div" + x).innerText = x;
}
}
</script>
</head>
<body>
<button onclick="testeval()">Click here</button>
<div id="div0"> </div>
<div id="div1"> </div>
<div id="div2"> </div>
<div id="div3"> </div>
<div id="div4"> </div>
<div id="div5"> </div>
<div id="div6"> </div>
</body>
</html>
I'm having some weird problem with evaluating the continue statement.
Within a for loop I'm trying to evaluate a string (generated somewhere
earlier) which basically has the continue statement in it. IE6 seems to
have major problems with that as it generates an error "Can't have
'continue' outside of loop". Does anyone know why and/or have a
workaround? I haven't tried any other browser since this one is the
only one available (company policy).
I have included some code to reproduce this behaviour. The first and
second if statements of the testeval function behave as expected. The
third one however produces the mentionned error.
Thanks in advance for any help.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Test Page</title>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html;
charset=ISO-8859-1" />
<style>
div {border:1px solid red;margin-top:2px;}
</style>
<script language="JavaScript" type="text/javascript">
function testeval() {
for (var x=0; x< 6; x++) {
document.getElementById("div" + x).innerHTML = " ";
if (x == 2) continue;
if (x == 4) eval("alert('next line will produce an error')");
if (x == 4) eval("continue");
document.getElementById("div" + x).innerText = x;
}
}
</script>
</head>
<body>
<button onclick="testeval()">Click here</button>
<div id="div0"> </div>
<div id="div1"> </div>
<div id="div2"> </div>
<div id="div3"> </div>
<div id="div4"> </div>
<div id="div5"> </div>
<div id="div6"> </div>
</body>
</html>