3

I have a Javascript function that's fired on the onclick event of a button on my webform. It's possible for invalid parameters to be passed to the function, in which case I'd like to throw an error so that the browser can report to the user that something went wrong, and that they might want to check their configuration settings. However, throwing an error causes a postback as the return false; statement is never reached.

In this situation, what sort of feedback can/should I give to the user? I don't particularly want to throw up an alert as I'd prefer something more subtle. Any/all suggestions appreciated.

3
  • Did you try with Exception Handling in Javascript? Try/catch Commented Apr 2, 2012 at 8:45
  • No, I want the error to be thrown. Commented Apr 2, 2012 at 8:47
  • @geekchic - Try/Catch includes the throw statement too. Commented Apr 2, 2012 at 8:58

2 Answers 2

1

Try Catch Finally in JavaScript Using exception handling you can throw the error as well as return the control as false based on your certain conditions

Sign up to request clarification or add additional context in comments.

Comments

0

1) For handling runtime errors:
use try/catch/finally
Reference: MDN try...catch

2) For the feedback:
Instead of using the alert you can use a Dialog animation with fade in and after two seconds fade out effect.

For example look to this demo:
http://sandbox.scriptiny.com/javascript-fading/

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.