Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1279
  • Last Modified:

more iframe issues

Ok it seems as I solve one problem with toggling the iframe designMode attribute, a new one crops up. The following function works in IE fine, in firefox it dies:


function ToggleDesignMode(strOnOrOff) // strOnOfOff will be either 'on' or 'off'.
{
    var strCurrTxt = document.getElementById("e_body").contentWindow.document.body.innerHTML;
    document.getElementById("e_body").contentWindow.document.open();
    document.getElementById("e_body").contentWindow.document.write(strCurrTxt);
    document.getElementById("e_body").contentWindow.document.close();
    document.getElementById("e_body").contentWindow.document.designMode = strOnOrOff;
    document.getElementById("e_body").contentWindow.focus();
}

Firefox complains about the 5th line:

     document.getElementById("e_body").contentWindow.document.designMode = strOnOrOff;

with the error:

    Error: uncaught exception: [Exception... "Access to restricted URI denied"  code: "1012" nsresult: "0x805303f   NS_ERROR_DOM_BAD_URI)"  location: "http://localhost/Test.js Line: 230"]

Thanks
0
minnirok
Asked:
minnirok
  • 3
2 Solutions
 
sara110Commented:
also check this link for testing
http://www.permadi.com/tutorial/flashGetObject/
0
 
minnirokAuthor Commented:
Ok, I ended up doing this to get around IE and FF each having their own issues with this. Can someone please let me know if they think this is OK. It 'works' but I'm not sure if there is some problem with it I just haven't run into yet.

function ToggleDesignMode(strOnOrOff)
{
    var ua = navigator.userAgent.toLowerCase();
    if (((ua.indexOf("msie") != -1) && (ua.indexOf("opera") == -1) && (ua.indexOf("webtv") == -1))) {
        // For IE, since it erases the content of the iframe when toggling designMode for some reason.
        // FF dies if I try to call this block, so I have to split it up.
        var strCurrTxt = document.getElementById("e_body").contentWindow.document.body.innerHTML;
        document.getElementById("e_body").contentWindow.document.open();
        document.getElementById("e_body").contentWindow.document.write(strCurrTxt);
        document.getElementById("e_body").contentWindow.document.close();
    }
    document.getElementById("e_body").contentWindow.document.designMode = strOnOrOff;
}

Thanks
0
 
siva350Commented:
That looks like it should work to me!
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now