dijit._editor.RichText._drawIframe
dojo.require("dijit._editor.RichText");
defined in dijit/_editor/RichText.js
Draws an iFrame using the existing one if one exists. Used by Mozilla, Safari, and Opera
Usage
function (/*String*/ html) (view source)
if(!this.iframe){ var ifr = this.iframe = dojo.doc.createElement("iframe"); ifr.id=this.id; // this.iframe.src = "about:blank"; // dojo.doc.body.appendChild(this.iframe); // console.debug(this.iframe.contentDocument.open()); // dojo.body().appendChild(this.iframe); var ifrs = ifr.style; // ifrs.border = "1px solid black"; ifrs.border = "none"; ifrs.lineHeight = "0"; // squash line height ifrs.verticalAlign = "bottom"; // ifrs.scrolling = this.height ? "auto" : "vertical"; this.editorObject = this.iframe; // get screen reader text for mozilla here, too this._localizedIframeTitles = dojo.i18n.getLocalization("dijit", "Textarea"); // need to find any associated label element and update iframe document title var label=dojo.query('label[for="'+this.id+'"]'); if(label.length){ this._localizedIframeTitles.iframeEditTitle = label[0].innerHTML + " " + this._localizedIframeTitles.iframeEditTitle; } } // opera likes this to be outside the with block // this.iframe.src = "javascript:void(0)";//dojo.uri.dojoUri("src/widget/templates/richtextframe.html") + ((dojo.doc.domain != currentDomain) ? ("#"+dojo.doc.domain) : ""); this.iframe.style.width = this.inheritWidth ? this._oldWidth : "100%"; if(this.height){ this.iframe.style.height = this.height; }else{ this.iframe.height = this._oldHeight; } var tmpContent; if(this.textarea){ tmpContent = this.srcNodeRef; }else{ tmpContent = dojo.doc.createElement('div'); tmpContent.style.display="none"; tmpContent.innerHTML = html; //append tmpContent to under the current domNode so that the margin //calculation below is correct this.editingArea.appendChild(tmpContent); } this.editingArea.appendChild(this.iframe); //do we want to show the content before the editing area finish loading here? //if external style sheets are used for the editing area, the appearance now //and after loading of the editing area won't be the same (and padding/margin //calculation above may not be accurate) // tmpContent.style.display = "none"; // this.editingArea.appendChild(this.iframe); var _iframeInitialized = false; // console.debug(this.iframe); // var contentDoc = this.iframe.contentWindow.document; // note that on Safari lower than 420+, we have to get the iframe // by ID in order to get something w/ a contentDocument property var contentDoc = this.iframe.contentDocument; contentDoc.open(); if(dojo.isAIR){ contentDoc.body.innerHTML = html; }else{ contentDoc.write(this._getIframeDocTxt(html)); } contentDoc.close(); // now we wait for onload. Janky hack! var ifrFunc = dojo.hitch(this, function(){ if(!_iframeInitialized){ _iframeInitialized = true; }else{ return; } if(!this.editNode){ try{ if(this.iframe.contentWindow){ this.window = this.iframe.contentWindow; this.document = this.iframe.contentWindow.document }else if(this.iframe.contentDocument){ // for opera this.window = this.iframe.contentDocument.window; this.document = this.iframe.contentDocument; } if(!this.document.body){ throw 'Error'; } }catch(e){ setTimeout(ifrFunc,500); _iframeInitialized = false; return; } dojo._destroyElement(tmpContent); this.onLoad(); }else{ dojo._destroyElement(tmpContent); this.editNode.innerHTML = html; this.onDisplayChanged(); } this._preDomFilterContent(this.editNode); }); ifrFunc();
parameter | type | description |
---|---|---|
html | String |