diff --git a/IPython/frontend/html/notebook/static/js/notebook.js b/IPython/frontend/html/notebook/static/js/notebook.js
index a651076..cd9e2b9 100644
--- a/IPython/frontend/html/notebook/static/js/notebook.js
+++ b/IPython/frontend/html/notebook/static/js/notebook.js
@@ -137,13 +137,13 @@ var IPython = (function (IPython) {
}
if (event.which === key.UPARROW && !event.shiftKey) {
var cell = that.get_selected_cell();
- if (cell.at_top()) {
+ if (cell && cell.at_top()) {
event.preventDefault();
that.select_prev();
};
} else if (event.which === key.DOWNARROW && !event.shiftKey) {
var cell = that.get_selected_cell();
- if (cell.at_bottom()) {
+ if (cell && cell.at_bottom()) {
event.preventDefault();
that.select_next();
};