diff --git a/src/resize.js b/src/resize.js
index 32282fd0f6fc0b2014af5429a680eac3299cc01f..c8d87d9ded58f88c153d4b57a5fea93901f7e310 100644
--- a/src/resize.js
+++ b/src/resize.js
@@ -42,16 +42,19 @@ function resize_helper(sc)
     var h = window.innerHeight - 20;
 
     /* Screen height based on debug console visibility  */
-    if (window.getComputedStyle(m).getPropertyValue("display") == 'none')
+    if (m != null)
     {
-        /* Get console height from spice.css .spice-message */
-        var mh = parseInt(window.getComputedStyle(m).getPropertyValue("height"), 10);
-        h = h - mh;
-    }
-    else
-    {
-        /* Show both div elements - spice-area and message-div */
-        h = h - m.offsetHeight - m.clientHeight;
+        if (window.getComputedStyle(m).getPropertyValue("display") == 'none')
+        {
+            /* Get console height from spice.css .spice-message */
+            var mh = parseInt(window.getComputedStyle(m).getPropertyValue("height"), 10);
+            h = h - mh;
+        }
+        else
+        {
+            /* Show both div elements - spice-area and message-div */
+            h = h - m.offsetHeight - m.clientHeight;
+        }
     }