By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,700 Members | 1,513 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,700 IT Pros & Developers. It's quick & easy.

designMode not working with IE

P: n/a
Hi,

I'm trying to build a web page where the user can insert text
dinamically. When the user hits a button, a new text box is created and
the user can insert text into it.

It's working nice with Firefox 1.0, but it's not working with IE
6.0.2800.1106 (W2K SP4)

function addText() {
doc = document.getElementById("desktop");

myIframe = document.createElement("iframe");
myIframe.id = "editFrame";
myIframe.name = "editFrame";
myIframe.style.border = "1px dotted";
myIframe.style.position = "relative";

doc.appendChild(myIframe);

if(document.all) {
document.editFrame.document.designMode = 'On';
} else {
document.getElementById("editFrame").contentDocume nt.designMode =
"on";
}
}

I did a test putting it inside an static page (below) and it worked.

<HTML>
<HEAD></HEAD>
<BODY>
<IFRAME NAME="editFrame"></IFRAME>
<SCRIPT>
document.editFrame.document.designMode = 'On';
</SCRIPT>
</BODY>
</HTML>

So, is it possible to do it on the fly? Any help?

TIA,

Bob

Jul 23 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a


Bob Rivers wrote:

I'm trying to build a web page where the user can insert text
dinamically. When the user hits a button, a new text box is created and
the user can insert text into it.
If you want a text box then use the DOM to create a textarea element e.g.
var textarea;
if (document.createElement && (textarea =
document.createElement('textarea'))) {
textarea.name = 'textareaName';
textarea.rows = 5;
textarea.cols = 40;
someElement.appendChild(textarea);
}
It's working nice with Firefox 1.0, but it's not working with IE
6.0.2800.1106 (W2K SP4)


So what happens with IE, do you get an error message?

It might be that you need to make sure that some document is in the
iframe before you try to script the document and its designMode property.

The following example here creates the iframe without problems with
Firefox 1.0, Netscape 7.2, and IE 6:

<html lang="en">
<head>
<title>dynamically creating an editable iframe with Mozilla and
IE/Win</title>
<script type="text/javascript">
function createEditableIframe (iframeName, parentElement, initialContent) {
var iframeElement;
if (document.createElement && (iframeElement =
document.createElement('iframe'))) {
iframeElement.id = iframeName;
iframeElement.name = iframeName;
iframeElement.width = '100%';
iframeElement.height = '200';
parentElement.appendChild(iframeElement);
var iframeWin = window.frames[iframeName];
if (iframeWin) {
iframeWin.document.open();
iframeWin.document.write(initialContent);
iframeWin.document.close();
iframeWin.document.designMode = 'on';
iframeWin.focus();
}
}
}

window.onload = function (evt) {
createEditableIframe(
'editFrame',
document.body,
[ '<html lang="en">',
'<head>',
'<title>example content<\/title>',
'<\/head>',
'<body>',
'<p>Try to edit this content.<\/p>',
'<\/body>',
'<\/html>'
].join('\r\n')
);
};
</script>
</head>
<body>

<h1>dynamically creating an editable iframe with Mozilla and IE/Win</h1>

</body>
</html>

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #2

P: n/a
Hi Bob

You might also want to take a look at HTMLArea,
http://www.interactivetools.com/free.../htmlarea.html. It provides
some extended editing features.

Cheers
Adam

Jul 23 '05 #3

P: n/a
Hi,

Thanks. It worked.

Bob
It might be that you need to make sure that some document is in the
iframe before you try to script the document and its designMode property.
The following example here creates the iframe without problems with
Firefox 1.0, Netscape 7.2, and IE 6:

<html lang="en">
<head>
<title>dynamically creating an editable iframe with Mozilla and
IE/Win</title>
<script type="text/javascript">
function createEditableIframe (iframeName, parentElement, initialContent) { var iframeElement;
if (document.createElement && (iframeElement =
document.createElement('iframe'))) {
iframeElement.id = iframeName;
iframeElement.name = iframeName;
iframeElement.width = '100%';
iframeElement.height = '200';
parentElement.appendChild(iframeElement);
var iframeWin = window.frames[iframeName];
if (iframeWin) {
iframeWin.document.open();
iframeWin.document.write(initialContent);
iframeWin.document.close();
iframeWin.document.designMode = 'on';
iframeWin.focus();
}
}
}


Jul 23 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.