finally

書式

finally { ... }

説明

finally{}はtryで発生したエラーの後に必ず処理する命令を指定することができます。

サンプルコード [実行]

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<title>Sample</title>
</head>
<body>
<script type="text/javascript"><!--
try {
v = javascript.version;
document.write("Version = "+v);
}catch(e){
document.write("Error = "+e);
}finally{
document.write("<br>エラーが発生しました");
}
// --></script>
</body>
</html>