Scroll To Top

JavaScript Error Handling

By Sreejesh SP Aug 20, 2013
This blog defines try, catch in JavaScript.

Below code use error handling in js.   

function Navigate() {

        try {

            addlert("Welcome guest!");


        catch (err) {

            txt = "There was an error on this page.\n\n";

            txt += "Error description: " + err.message + "\n\n";

            txt += "Click OK to continue.\n\n";






    <form id="form1" runat="server">


        <%-- <asp button type="button" onclick="alert('Welcome!')">Click Me!</button>--%>

        <asp:Button ID="Button1" Text="Open Web site" OnClientClick="Navigate()" runat="server" />