Toggle designMode in IE

S

Simon Rigby

Hi folks,

I'm trying to switch an iFrame in and out of design mode by way of a
script. As you can see from the method it is intended to be cross
browser compatible (or FF and IE at least). The FF version (the else
branch) works fine but the if branch (IE) switches into design Mode but
wont switch back.

Below is my method, the iFrame tages and the anchor used to trigger the
function call. Any help greatly appreciated.

--- Method ---
function ToggleEditMode(element) {
if (document.all) {
if (frames[element].document.designMode == "on") {
frames[element].document.designMode = "off";
} else {
frames[element].document.designMode = "on";
}
} else {
if
(document.getElementById(element).contentDocument.designMode=="on") {
document.getElementById(element).contentDocument.designMode="off";
} else {
document.getElementById(element).contentDocument.designMode="on";
}
}
return;
}

--- iFrame ---
<iframe name="edit" id="edit" WIDTH="512" HEIGHT="214"
CONTENTEDITABLE="True"></iframe>

--- anchor ---
<a href="javascript:ToggleEditMode('edit')">Edit</a>

Thanks
 
M

marss

Simon said:
function ToggleEditMode(element) {
if (document.all) {
if (frames[element].document.designMode == "on") {
frames[element].document.designMode = "off";
} else {
frames[element].document.designMode = "on";

Possible values for designMode property in IE is "On" and "Off"
 
S

Simon Rigby

Ok thanks, yes a case sens. thing. Now switching in and out but when I
switch it out of design mode the content of the iFRame (newly typed
content) disappears?

Simon
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top