diff options
author | Joris Guyonvarch | 2015-02-18 20:40:24 +0100 |
---|---|---|
committer | Joris Guyonvarch | 2015-02-18 20:40:24 +0100 |
commit | 3acc5f10fbd8bff4914ba261861b1e39674c01f4 (patch) | |
tree | 6b2bdefd23cba4b3f320b98c1ff119bc2df72907 | |
parent | d712cc2422027a73e8904eb6cecb9078749bb8d3 (diff) |
Show a notFound page if the requested page does not exists
-rw-r--r-- | router.js | 11 |
1 files changed, 9 insertions, 2 deletions
@@ -19,14 +19,21 @@ } } }; - xhr.send(); + try { + xhr.send(); + } catch(err) { + errorHandler && errorHandler(err); + } }; function router() { var url = location.hash.slice(2) || 'presentation'; + var contentElement = document.getElementById('content'); fetchFile('Pages/' + url + '.md', function(contentMd) { - var contentElement = document.getElementById('content'); contentElement.innerHTML = markdown.toHTML(contentMd); + }, function() { + var notFoundPage = '<h1>Page non trouvée</h1><a href="#">Retour à l\'accueil</a>'; + contentElement.innerHTML = notFoundPage; }); } |