문제

I have a javascript function which is called onclick of a button. It is working fine in chrome and firefox. It basically places some validation checks, so that in case of incomplete information form is not submitted to the server.

My question is that if in some browser the javascript function has some syntax errors, how can I ignore the errors, so that validation function is bypassed, after all validation function is just to reduce invalid form submits and checks are also placed on the server.

도움이 되었습니까?

해결책

Its very unlikely (if not impossible), that you write some ECMAscript code which works fine on some engines and throws syntax errors on others. Unless you're dealing with something like IE4 or real old Netscape browsers.

However, you can of course always wrap your code into try..catch blocks, like

try {
   // beautiful javascript code
} catch( ex ) {
   alert(ex.message);
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top