Try catch { call function } - Javascript Statement

Javascript examples for Statement:try catch finally

Description

Try catch { call function }

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
    window.onload=( function() {/*from   w w  w  .  j a va2  s  . c o  m*/
function setGrid()
{
    console.log('inside setGrid');
}
try {
    Typekit.load({
        loading: function() { },
        active: function() { setGrid(); },
        inactive: function() { }
    })
} catch(e) {
    console.log('error') //works
    setGrid(); //doesn't get called
}
    });

      </script> 
   </head> 
   <body>  
   </body>
</html>

Related Tutorials