سؤال

كنت expreefacting لبناء محرر الصفحات. قضية واحدة فقط قادني مجنون في فايرفوكس.

رمز الصفحة أدناه:

<body>
<iframe WIDTH=200 HEIGHT=200 id="myEditor"></iframe>
<script>

    function getIFrameDocument(sID){
        // if contentDocument exists, W3C compliant (Mozilla)
        if (document.getElementById(sID).contentDocument){
            alert("mozilla"); // comment out this line and it doesn't work
            return document.getElementById(sID).contentDocument;
        } else {
            // IE
            alert("IE");
            //return document.getElementById(sID);
            return document.frames[sID].document;
        }
    }

    getIFrameDocument("myEditor").designMode = "On";

</script>

</body>

فقط تحقق مما إذا كان من المفترض تعيين "DesignMode" بطريقة موزيلا أو أي طريقة. عند تحميل الصفحة، ينبثق "Mozilla"؛ انقر فوق منطقة iFrame، والتركيز موجود على iFrame ويمكنني إدخال لوحة المفاتيح.

هذا يبدو جيدا، ولكن عندما أعلق الخط "تنبيه (" موزيلا ")؛"لا يعمل. "تصميم DesignMode" هو "إيقاف" كما تظهر Firebug.

هذا سلكي جدا. لماذا يمكن أن يؤثر التنبيه على دوم وجافا سكريبت؟ راجع للشغل، لي فايرفوكس 3.0.6.

هل كانت مفيدة؟

المحلول

لأن التنبيه يعطي وقت iFrame لتحميل. يجب عليك تعيين DesignMode إلى "ON" فقط بعد تحميل مستند iFrame:

iframe.onload = function() {
    doc.designMode = "on";
};
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top