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
LVL 7
minnirokAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
HTML

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.