Index: /CKEditor/branches/versions/3.1.x/CHANGES.html
===================================================================
--- /CKEditor/branches/versions/3.1.x/CHANGES.html	(revision 4686)
+++ /CKEditor/branches/versions/3.1.x/CHANGES.html	(revision 4687)
@@ -169,4 +169,5 @@
 		<li><a href="http://dev.fckeditor.net/ticket/4518">#4518</a> : Fixed unable to open dialog without editor focus in IE.</li>
 		<li><a href="http://dev.fckeditor.net/ticket/4519">#4519</a> : Fixed maximize without editor focus throw error in IE.</li>
+		<li><a href="http://dev.fckeditor.net/ticket/4768">#4768</a> : Fixed open context menu in IE throws js error when focus is not inside document.</li>
 		<li>Updated the following language files:<ul>
 			<li><a href="http://dev.fckeditor.net/ticket/3947">#3947</a> : Arabic;</li>
Index: /CKEditor/branches/versions/3.1.x/_source/plugins/contextmenu/plugin.js
===================================================================
--- /CKEditor/branches/versions/3.1.x/_source/plugins/contextmenu/plugin.js	(revision 4686)
+++ /CKEditor/branches/versions/3.1.x/_source/plugins/contextmenu/plugin.js	(revision 4687)
@@ -89,5 +89,8 @@
 
 					if ( CKEDITOR.env.ie )
-						editor.getSelection().unlock();
+					{
+						var selection = editor.getSelection();
+						selection && selection.unlock();
+					}
 
 					this.onHide && this.onHide();
@@ -182,5 +185,8 @@
 				{
 					if ( event.data.$.button == 2 )
-						this.editor.getSelection().lock();
+					{
+						var selection = this.editor.getSelection();
+						selection && selection.lock();
+					}
 				}, this );
 			}
