wrote on 13 dec 2007 in comp.lang.javascript
:
I want to stop the execution of the code when the value of k>100 in
the function
function aa()
{
if (k>100)
{
//command to kill the execution
}
}
I saw the break to break the loop, but I'm trying to just stop the
javascript function from continueing execution. I can work around it
in other ways, but that would require alot of redundant code or
another function, both of which I'd like to avoid.
This is contrary to moduled programming, and would be a shame to have
introduced.
I am glad that it is not possible. A function ends when it returns
[something or nothing].
The global program ends, when there is no more global code.
=================================================
That being said, it is simple to do in browser js:
function aa(k) {
if (k>100) {
window.location.href = 'http://cnn.com/';
};
};
Though this is not what you probably ment,
it does what you asked.
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)