Here is the code I simplified, but the nature of the problem is the same:
var counter=0;
function test(){
window.onclick="return;";
t.value=counter;
counter++;
setTimeout(test,1000);
}
t=document.createElement("textarea");
document.body.insertBefore(t, document.body.firstChild);
test();
Sets up a timer, however, as you can see, the clock does not stop (i.e. function exits) after I clicked the window. So where is the problem?
Edit: The motivation of this question comes from:Early exit from function?
Edit^2: Then there is noway to make 'onlick' trigger the returning value of test()? (i.e. equivalent of asking whether a function can return as its super-function)