Re: Non-editable custom object

  •  11-05-2004, 4:49 PM

    Re: Non-editable custom object

    OK.  I think I got it sorted out. 
     
    You need the UNSELECTABLE attribute on every element inside the containing object, and CONTENTEDITABLE="false" set on the outside container, plus you have to trap the onmousedown event of the outside element and force the editor to control select the object.
     
    The following code works alright, but I'd be interested in suggestions.
     

    <div id="outerObj" CONTENTEDITABLE="false" onmousedown="selectObject('YourEditorID', this);">
        <div UNSELECTABLE="ON">Some text</div>
    </div>
    <script language="javascript">
    function selectObject(editorID, oObj)
    {
       var editor = document.getElementById(editorID);

       var r = editor.document.body.createControlRange();

        r.add(oObj);

        r.select();

    }

    </script>
     
View Complete Thread