Index: /CKEditor/trunk/_source/core/dom/element.js
===================================================================
--- /CKEditor/trunk/_source/core/dom/element.js	(revision 3268)
+++ /CKEditor/trunk/_source/core/dom/element.js	(revision 3269)
@@ -1208,4 +1208,42 @@
 					break;
 			}
+		},
+
+		/**
+		 * Returns the inner document of this IFRAME element.
+		 * @returns {CKEDITOR.dom.document} The inner document.
+		 */
+		getFrameDocument : function()
+		{
+			var $ = this.$;
+
+			try
+			{
+				// In IE, with custom document.domain, it may happen that
+				// the iframe is not yet available, resulting in "Access
+				// Denied" for the following property access.
+				void( $.contentWindow.document );
+			}
+			catch ( e )
+			{
+				// Trick to solve this issue, forcing the iframe to get ready
+				// by simply setting its "src" property.
+				$.src = $.src;
+
+				// In IE6 though, the above is not enough, so we must pause the
+				// execution for a while, giving it time to think.
+				if ( CKEDITOR.env.ie && CKEDITOR.env.version < 7 )
+				{
+					window.showModalDialog(
+						'javascript:document.write("' +
+							'<script>' +
+								'window.setTimeout(' +
+									'function(){window.close();}' +
+									',50);' +
+							'</script>")' );
+				}
+			}
+
+			return $ && new CKEDITOR.dom.document( $.contentWindow.document );
 		}
 	});
Index: /CKEditor/trunk/_source/core/env.js
===================================================================
--- /CKEditor/trunk/_source/core/env.js	(revision 3268)
+++ /CKEditor/trunk/_source/core/env.js	(revision 3269)
@@ -70,5 +70,10 @@
 			mac	: ( agent.indexOf( 'macintosh' ) > -1 ),
 
-			quirks : ( document.compatMode == 'BackCompat' )
+			quirks : ( document.compatMode == 'BackCompat' ),
+
+			isCustomDomain : function()
+			{
+				return this.ie && document.domain != window.location.hostname;
+			}
 		};
 
Index: /CKEditor/trunk/_source/plugins/dialog/plugin.js
===================================================================
--- /CKEditor/trunk/_source/plugins/dialog/plugin.js	(revision 3268)
+++ /CKEditor/trunk/_source/plugins/dialog/plugin.js	(revision 3269)
@@ -368,7 +368,8 @@
 			{
 				CKEDITOR.document.on( 'keydown', focusKeydownHandler, this, null, 0 );
+
 				if ( CKEDITOR.env.ie6Compat )
 				{
-					var coverDoc = new CKEDITOR.dom.document( frames( 'cke_dialog_background_iframe' ).document );
+					var coverDoc = CKEDITOR.document.getById( 'cke_dialog_background_iframe' ).getFrameDocument();
 					coverDoc.on( 'keydown', focusKeydownHandler, this, null, 0 );
 				}
@@ -1449,5 +1450,5 @@
 				if ( CKEDITOR.env.ie6Compat )
 				{
-					var coverDoc = new CKEDITOR.dom.document( frames( 'cke_dialog_background_iframe' ).document );
+					var coverDoc = CKEDITOR.document.getById( 'cke_dialog_background_iframe' ).getFrameDocument();
 					coverDoc.removeListener( 'mousemove', mouseMoveHandler );
 					coverDoc.removeListener( 'mouseup', mouseUpHandler );
@@ -1465,5 +1466,5 @@
 					if ( CKEDITOR.env.ie6Compat )
 					{
-						var coverDoc = new CKEDITOR.dom.document( frames( 'cke_dialog_background_iframe' ).document );
+						var coverDoc = CKEDITOR.document.getById( 'cke_dialog_background_iframe' ).getFrameDocument();
 						coverDoc.on( 'mousemove', mouseMoveHandler );
 						coverDoc.on( 'mouseup', mouseUpHandler );
@@ -1516,5 +1517,5 @@
 				if ( CKEDITOR.env.ie6Compat )
 				{
-					var coverDoc = new CKEDITOR.dom.document( frames( 'cke_dialog_background_iframe' ).document );
+					var coverDoc = CKEDITOR.document.getById( 'cke_dialog_background_iframe' ).getFrameDocument();
 					coverDoc.on( 'mousemove', mouseMoveHandler, dialog, { part : partName } );
 					coverDoc.on( 'mouseup', mouseUpHandler, dialog, { part : partName } );
@@ -1585,5 +1586,5 @@
 				if ( CKEDITOR.env.ie6Compat )
 				{
-					var coverDoc = new CKEDITOR.dom.document( frames( 'cke_dialog_background_iframe' ).document );
+					var coverDoc = CKEDITOR.document.getById( 'cke_dialog_background_iframe' ).getFrameDocument();
 					coverDoc.removeListener( 'mouseup', mouseUpHandler );
 					coverDoc.removeListener( 'mousemove', mouseMoveHandler );
@@ -1623,7 +1624,34 @@
 		if ( CKEDITOR.env.ie6Compat )
 		{
-			html.push( '<iframe hidefocus="true" frameborder="0" name="cke_dialog_background_iframe" src="javascript: \'\'" ',
-					'style="position: absolute; left: 0px; top: 0px; width: 100%; height: 100%; ',
-					'progid:DXImageTransform.Microsoft.Alpha(opacity=0)" ></iframe>' );
+			// Support for custom document.domain in IE.
+			var isCustomDomain = CKEDITOR.env.isCustomDomain();
+
+			html.push( 
+				'<iframe' +
+					' hidefocus="true"' +
+					' frameborder="0"' +
+					' id="cke_dialog_background_iframe"' +
+					' src="javascript:void(' );
+
+			html.push( 
+					isCustomDomain ?
+						'(function(){' +
+							'document.open();' +
+							'document.domain=\'' + document.domain + '\';' +
+							'document.close();' +
+						'})()'
+					:
+						'0' );
+
+			html.push( 
+					')"' +
+					' style="' +
+						'position:absolute;' +
+						'left:0;' +
+						'top:0;' +
+						'width:100%;' +
+						'height: 100%;' +
+						'progid:DXImageTransform.Microsoft.Alpha(opacity=0)">' +
+				'</iframe>' );
 		}
 
Index: /CKEditor/trunk/_source/plugins/dialogui/plugin.js
===================================================================
--- /CKEditor/trunk/_source/plugins/dialogui/plugin.js	(revision 3268)
+++ /CKEditor/trunk/_source/plugins/dialogui/plugin.js	(revision 3269)
@@ -1,3 +1,3 @@
-/*
+﻿/*
 Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
 For licensing, see LICENSE.html or http://ckeditor.com/license
@@ -642,6 +642,30 @@
 				{
 					_.frameId = CKEDITOR.tools.getNextNumber() + '_fileInput';
-					var html = [ '<iframe frameborder="0" allowtransparency="0" class="cke_dialog_ui_input_file" id="',
-						_.frameId, '" src="javascript: void(0)" ></iframe>' ];
+
+					// Support for custom document.domain in IE.
+					var isCustomDomain = CKEDITOR.env.ie && document.domain != window.location.hostname;
+
+					var html = [ 
+						'<iframe' +
+							' frameborder="0"' +
+							' allowtransparency="0"' +
+							' class="cke_dialog_ui_input_file"' +
+							' id="', _.frameId, '"' +
+							' src="javascript:void(' ];
+
+					html.push( 
+							isCustomDomain ?
+								'(function(){' +
+									'document.open();' +
+									'document.domain=\'' + document.domain + '\';' +
+									'document.close();' +
+								'})()'
+							:
+								'0' );
+
+					html.push( 
+							')">' +
+						'</iframe>' );
+
 					return html.join( '' );
 				};
@@ -1194,6 +1218,6 @@
 				getInputElement : function()
 				{
-					return new CKEDITOR.dom.element( CKEDITOR.document.getById( this._.frameId )
-						.$.contentWindow.document.forms[0].elements[0] );
+					return new CKEDITOR.dom.element( 
+						CKEDITOR.document.getById( this._.frameId ).getFrameDocument().$.forms[0].elements[0] );
 				},
 
@@ -1218,9 +1242,15 @@
 				{
 					var frameElement = CKEDITOR.document.getById( this._.frameId ),
-						frameDocument = frameElement.$.contentWindow.document,
+						frameDocument = frameElement.getFrameDocument(),
 						elementDefinition = this._.definition,
 						buttons = this._.buttons;
-					frameDocument.open();
-					frameDocument.write( [ '<html><head><title></title></head><body style="margin: 0; overflow: hidden; background: transparent;">',
+
+					frameDocument.$.open();
+
+					// Support for custom document.domain in IE.
+					if ( CKEDITOR.env.isCustomDomain() )
+						frameDocument.$.domain = document.domain;
+
+					frameDocument.$.write( [ '<html><head><title></title></head><body style="margin: 0; overflow: hidden; background: transparent;">',
 							'<form enctype="multipart/form-data" method="POST" action="',
 							CKEDITOR.tools.htmlEncode( elementDefinition.action ),
@@ -1233,5 +1263,6 @@
 							'</form>',
 							'</body></html>' ].join( '' ) );
-					frameDocument.close();
+
+					frameDocument.$.close();
 
 					for ( var i = 0 ; i < buttons.length ; i++ )
Index: /CKEditor/trunk/_source/plugins/panel/plugin.js
===================================================================
--- /CKEditor/trunk/_source/plugins/panel/plugin.js	(revision 3268)
+++ /CKEditor/trunk/_source/plugins/panel/plugin.js	(revision 3269)
@@ -91,6 +91,19 @@
 						'<iframe id="', id, '_frame"' +
 							' frameborder="0"' +
-							' src="javascript:void(0)"' +
-						'></iframe>' );
+							' src="javascript:void(' );
+
+			output.push(
+							// Support for custom document.domain in IE.
+							CKEDITOR.env.isCustomDomain() ?
+								'(function(){' +
+									'document.open();' +
+									'document.domain=\'' + document.domain + '\';' +
+									'document.close();' +
+								'})()'
+							:
+								'0' );
+
+			output.push(
+						')"></iframe>' );
 		}
 
@@ -110,11 +123,15 @@
 			if ( this.forceIFrame || this.css.length )
 			{
-				var iframe = this.document.getById( 'cke_' + this.id + '_frame' );
-				var doc = new CKEDITOR.dom.document( iframe.$.contentWindow.document );
-
-				var className = iframe.getParent().getParent().getAttribute( 'class' );
+				var iframe = this.document.getById( 'cke_' + this.id + '_frame' ),
+					className = iframe.getParent().getParent().getAttribute( 'class' ),
+					doc = iframe.getFrameDocument();
 
 				// Initialize the IFRAME document body.
 				doc.$.open();
+
+				// Support for custom document.domain in IE.
+				if ( CKEDITOR.env.isCustomDomain() )
+					doc.$.domain = document.domain;
+
 				doc.$.write(
 					'<!DOCTYPE html>' +
Index: /CKEditor/trunk/_source/plugins/wysiwygarea/plugin.js
===================================================================
--- /CKEditor/trunk/_source/plugins/wysiwygarea/plugin.js	(revision 3268)
+++ /CKEditor/trunk/_source/plugins/wysiwygarea/plugin.js	(revision 3269)
@@ -105,6 +105,6 @@
 						fireMode;
 
-					// The following information is needed for IE only.
-					var isCustomDomain = CKEDITOR.env.ie && document.domain != window.location.hostname;
+					// Support for custom document.domain in IE.
+					var isCustomDomain = CKEDITOR.env.isCustomDomain();
 
 					// Creates the iframe that holds the editable document.
@@ -344,5 +344,5 @@
 							getData : function()
 							{
-								var data = iframe.$.contentWindow.document.body.innerHTML;
+								var data = iframe.getFrameDocument().getBody().getHtml();
 
 								if ( editor.dataProcessor )
@@ -354,10 +354,10 @@
 							getSnapshotData : function()
 							{
-								return iframe.$.contentWindow.document.body.innerHTML;
+								return iframe.getFrameDocument().getBody().getHtml();
 							},
 
 							loadSnapshotData : function( data )
 							{
-								iframe.$.contentWindow.document.body.innerHTML = data;
+								iframe.getFrameDocument().getBody().setHtml( data );
 							},
 
