explorer crash after switching to designMode

Discussion in 'Javascript' started by Thomas, Jan 25, 2004.

  1. Thomas

    Thomas Guest

    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 it works perfectly
    (even it doesn't stop loading the page, but this doesn't matter), but
    the whole IE crashes and shuts down itself without reason. Can you
    help? Has someone had the same problem?
    I already switched the order for filling the iframe
    in IE -> first switch to designMode & then fill
    in Mozilla -> first fill designMode & then switch

    My code looks something like this (abbreviated):

    function transformIFrame(content,element) {
    iFrame = document.createElement("iframe");
    iFrame.setAttribute("id","editArea");
    iFrame.setAttribute("frameborder","0");
    iFrame.setAttribute("marginwidth","0px");
    iFrame.setAttribute("marginheight","0px");
    iFrame.style.border = "0px";
    iFrame.style.padding ="0px";

    editAreaHeight = element.offsetHeight;
    editAreaWidth = element.offsetWidth;

    if(moz) {
    element.parentNode.replaceChild(iFrame,element);
    } else {
    element.replaceNode(iFrame);
    }

    iFrame = document.getElementById("editArea");
    iFrame.height = editAreaHeight;
    iFrame.width = editAreaWidth;

    editArea = iFrame.contentWindow.document;

    styleCSS = "<style>BODY { font-size: 9pt; }</style>";

    if(!moz) {
    editArea.write("<html><head><title></title>" + styleCSS +
    "</head><body>" + content + "</body></html>");
    editArea.designMode = "On";
    } else {
    editArea.write("<html><head><title></title>" + styleCSS +
    "</head><body>" + content + "</body></html>");
    editArea.designMode = "On";
    }
    iFrame.contentWindow.focus();
    }

    Thx for your help
    Bye, Thomas

    --

    "It's a Texan thing - y'all wouldn't understand!" - read in San
    Antonio,
    July 2003

    ------------------------------------------------------------------------
    Thomas, Jan 25, 2004
    #1
    1. Advertising

  2. Thomas wrote:


    > 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 it works perfectly
    > (even it doesn't stop loading the page, but this doesn't matter), but
    > the whole IE crashes and shuts down itself without reason. Can you
    > help? Has someone had the same problem?
    > I already switched the order for filling the iframe
    > in IE -> first switch to designMode & then fill
    > in Mozilla -> first fill designMode & then switch
    >
    > My code looks something like this (abbreviated):
    >
    > function transformIFrame(content,element) {
    > iFrame = document.createElement("iframe");
    > iFrame.setAttribute("id","editArea");
    > iFrame.setAttribute("frameborder","0");
    > iFrame.setAttribute("marginwidth","0px");
    > iFrame.setAttribute("marginheight","0px");
    > iFrame.style.border = "0px";
    > iFrame.style.padding ="0px";
    >
    > editAreaHeight = element.offsetHeight;
    > editAreaWidth = element.offsetWidth;
    >
    > if(moz) {
    > element.parentNode.replaceChild(iFrame,element);
    > } else {
    > element.replaceNode(iFrame);
    > }
    >
    > iFrame = document.getElementById("editArea");
    > iFrame.height = editAreaHeight;
    > iFrame.width = editAreaWidth;
    >
    > editArea = iFrame.contentWindow.document;
    >
    > styleCSS = "<style>BODY { font-size: 9pt; }</style>";
    >
    > if(!moz) {
    > editArea.write("<html><head><title></title>" + styleCSS +
    > "</head><body>" + content + "</body></html>");


    Put
    editArea.close();
    here.

    > editArea.designMode = "On";
    > } else {
    > editArea.write("<html><head><title></title>" + styleCSS +
    > "</head><body>" + content + "</body></html>");


    Try
    editArea.close();
    here after the write and before you set designMode. Just a guess, test
    yourself.

    > editArea.designMode = "On";
    > }
    > iFrame.contentWindow.focus();




    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
    Martin Honnen, Jan 25, 2004
    #2
    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:
    452
    Marcel Balcarek
    Nov 12, 2003
  2. Replies:
    0
    Views:
    486
  3. thomas
    Replies:
    2
    Views:
    99
    thomas
    Nov 11, 2003
  4. VK
    Replies:
    6
    Views:
    107
  5. Danny
    Replies:
    11
    Views:
    245
    Danny
    Jun 27, 2007
Loading...

Share This Page