Using onError

Here are more constructs not available in PHP. Using either the onError event, or a combination of the try and catch keywords, you can catch JavaScript errors and deal with them yourself.
Events are actions that can be detected by JavaScript. Every element on a web page has certain events that can trigger JavaScript functions. For example, the onClick event of a button element can be set to call a function and make it run whenever a user clicks on the button.

onError = errorHandler
document.writ("Welcome to this website") // Deliberate error
function errorHandler(message, url, line)
out = "Sorry, an error was encountered.\n\n";
out += "Error: " + message + "\n";
out += "URL: " + url + "\n";
out += "Line: " + line + "\n\n";
out += "Click OK to continue.\n\n";
return true;