/*\r
-Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.\r
+Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.\r
For licensing, see LICENSE.html or http://ckeditor.com/license\r
*/\r
\r
exec : function( editor )\r
{\r
var sHTML,\r
- isCustomDomain = CKEDITOR.env.ie && document.domain != window.location.hostname;\r
- if ( editor.config.fullPage )\r
- sHTML = editor.getData();\r
+ config = editor.config,\r
+ baseTag = config.baseHref ? '<base href="' + config.baseHref + '"/>' : '',\r
+ isCustomDomain = CKEDITOR.env.isCustomDomain();\r
+\r
+ if ( config.fullPage )\r
+ {\r
+ sHTML = editor.getData()\r
+ .replace( /<head>/, '$&' + baseTag )\r
+ .replace( /[^>]*(?=<\/title>)/, editor.lang.preview );\r
+ }\r
else\r
{\r
var bodyHtml = '<body ',\r
- body = CKEDITOR.document.getBody(),\r
- baseTag = ( editor.config.baseHref.length > 0 ) ? '<base href="' + editor.config.baseHref + '" _cktemp="true"></base>' : '';\r
+ body = editor.document && editor.document.getBody();\r
+\r
+ if ( body )\r
+ {\r
+ if ( body.getAttribute( 'id' ) )\r
+ bodyHtml += 'id="' + body.getAttribute( 'id' ) + '" ';\r
+ if ( body.getAttribute( 'class' ) )\r
+ bodyHtml += 'class="' + body.getAttribute( 'class' ) + '" ';\r
+ }\r
\r
- if ( body.getAttribute( 'id' ) )\r
- bodyHtml += 'id="' + body.getAttribute( 'id' ) + '" ';\r
- if ( body.getAttribute( 'class' ) )\r
- bodyHtml += 'class="' + body.getAttribute( 'class' ) + '" ';\r
bodyHtml += '>';\r
\r
sHTML =\r
'<head>' +\r
baseTag +\r
'<title>' + editor.lang.preview + '</title>' +\r
- '<link href="' + editor.config.contentsCss + '" type="text/css" rel="stylesheet" _cktemp="true"/>' +\r
+ CKEDITOR.tools.buildStyleHtml( editor.config.contentsCss ) +\r
'</head>' + bodyHtml +\r
editor.getData() +\r
'</body></html>';\r
\r
if ( !isCustomDomain )\r
{\r
+ oWindow.document.open();\r
oWindow.document.write( sHTML );\r
oWindow.document.close();\r
}\r