diff --git a/typo3/sysext/backend/Resources/Public/JavaScript/ContextMenu.js b/typo3/sysext/backend/Resources/Public/JavaScript/ContextMenu.js
index 057c275ef0f87e7bd625a651f3eb81b7c9b8ece2..e1ca31e9511e35f353e72ca0bdb7ff1100b531c6 100644
--- a/typo3/sysext/backend/Resources/Public/JavaScript/ContextMenu.js
+++ b/typo3/sysext/backend/Resources/Public/JavaScript/ContextMenu.js
@@ -165,8 +165,8 @@ define(['jquery', 'TYPO3/CMS/Backend/ContextMenuActions'], function ($, ContextM
         var x = this.mousePos.X;
         var y = this.mousePos.Y;
         var dimsWindow = {
-            width: $(document).width() - 20, // saving margin for scrollbars
-            height: $(document).height()
+            width: $(window).width() - 20, // saving margin for scrollbars
+            height: $(window).height()
         };
 
         // dimensions for the context menu