Toggle designMode in IE

Discussion in 'Javascript' started by Simon Rigby, May 17, 2006.

  1. Simon Rigby

    Simon Rigby Guest

    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
    Simon Rigby, May 17, 2006
    #1
    1. Advertising

  2. Simon Rigby

    marss Guest

    Simon Rigby wrote:
    > 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"
    marss, May 18, 2006
    #2
    1. Advertising

  3. Simon Rigby

    Simon Rigby Guest

    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
    Simon Rigby, May 18, 2006
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Marcel Balcarek

    Using DesignMode in ASP.NET

    Marcel Balcarek, Nov 12, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    464
    Marcel Balcarek
    Nov 12, 2003
  2. Natty Gur

    Re: DesignMode for webforms...

    Natty Gur, Jun 4, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    381
    Galore
    Jun 4, 2004
  3. =?Utf-8?B?TWFya3VzIFJ5dHRlcmt1bGw=?=

    Masterpages/themes messes up designmode

    =?Utf-8?B?TWFya3VzIFJ5dHRlcmt1bGw=?=, Feb 27, 2006, in forum: ASP .Net
    Replies:
    3
    Views:
    1,387
    =?Utf-8?B?TWFya3VzIFJ5dHRlcmt1bGw=?=
    Feb 28, 2006
  4. Erik
    Replies:
    3
    Views:
    543
  5. Christophe Peillet

    Changed property values not reflected in DesignMode

    Christophe Peillet, Jan 9, 2006, in forum: ASP .Net Web Controls
    Replies:
    6
    Views:
    291
    Steven Cheng[MSFT]
    Jan 12, 2006
Loading...

Share This Page