473,320 Members | 1,612 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

designMode not working with IE

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
3 5138


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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Thomas | last post by:
Hy dudes, I have a strange problem. I dynamically create an IFrame with JavaScript and then fill in some content. Afterwards I want to switch to designMode. There the trouble starts. In Mozilla...
2
by: Lecture Snoddddgrass | last post by:
Hi, When I create a UserControl-derived object, I often expose various public properties. One of the things that I hate about the WinForms designer is that if I decide to embed one of these...
5
by: Larry | last post by:
I'm currently using designMode in a page, and it's been working for IE6 on Windows, but I'm hearing complaints that it's not working on IE6 on Mac. I had done some research on this before deciding...
29
by: Charles Law | last post by:
Further to my issue about user controls, I have a problem with DesignMode. Here is the project hierarchy: MainApp |_ Project1 |_ SubProject (UserControl) SubProject has a default constructor...
1
by: Paul W | last post by:
I'm having trouble detecting whether my Control is in DesignMode. I'm deriving a class from TreeView; Public Class ExplorerView Inherits TreeView ... End Class
4
by: Kyjan | last post by:
Greetings! In doing some research, I've learned that some other people have had problems with Me.DesignMode not working correctly when it's used in a user control that is placed on another form....
1
by: Larry | last post by:
I have a page which uses designMode which is working on IE but I'm having a devil of a time getting it to work in Safari 3. Is there any working code example of designMode which works on Safari? ...
2
by: graeme g | last post by:
ii i've been developing some usercontrols... and sudden the property designmode no longer works.. if i test it value at designtime it always comes back false... i've made a work around if...
3
by: Sagaert Johan | last post by:
Hi I stumbled to this : I have a form and in the contructor i put if (this.DesignMode) return; other code here The IDE designer throws an exception and points to a line in the 'other
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.