X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=js%2Futils.js;h=2bd2cfa5e7c28a1e8a2c920c70963ed0f7614829;hb=c935a4090e3f152dd5549217d69b5b5036197024;hp=cb1c0db3a4aef078ae75c9032e14b17c9493c696;hpb=1ccb5999a69a19289b6ef53e0501913c4754747b;p=fa-stable.git diff --git a/js/utils.js b/js/utils.js index cb1c0db3..2bd2cfa5 100644 --- a/js/utils.js +++ b/js/utils.js @@ -11,14 +11,10 @@ // Function is called when an answer arrives. function(result, errors) { - // Write errors to the debug div. - document.getElementById('msgbox').innerHTML = errors; - // Write the answer. if (result) { for(var i in result ) { atom = result[i]; - cmd = atom['n']; property = atom['p']; type = atom['c']; @@ -47,13 +43,16 @@ } else { errors = errors+'
Unknown ajax function: '+cmd; } - } - Behaviour.apply(); + } + // Write errors to the debug div. + document.getElementById('msgbox').innerHTML = errors; + + Behaviour.apply(); if (errors.length>0) window.scrollTo(0,0); //document.getElementById('msgbox').scrollIntoView(true); // Restore focus if we've just lost focus because of DOM element refresh - setFocus(); + setFocus(); } }, false // do not disable caching @@ -168,6 +167,7 @@ function setFocus(name, byId) { el = document.getElementById(name); else el = document.getElementsByName(name)[0]; + if(el && el.focus) { // The timeout is needed to prevent unpredictable behaviour on IE & Gecko. // Using tmp var prevents crash on IE5