exeCommand这是什么东东啊?

解决方案 »

  1.   


    <title>HTML 编辑器</title>
    <script>
    function BtnOver(btn){
    btn.style.borderTopColor="#efece8";
    btn.style.borderBottomColor="#888070";
    btn.style.borderLeftColor="#efece8";
    btn.style.borderRightColor="#888070";
    }
    function BtnClick(btn){
    btn.style.borderTopColor="#888070";
    btn.style.borderBottomColor="#efece8";
    btn.style.borderLeftColor="#888070";
    btn.style.borderRightColor="#efece8";
    }
    function BtnOut(btn){
    btn.style.borderColor="#d9cec4";
    }function doCreateLink(){
    doc.execCommand('CreateLink');
    Editor.focus();
    }
    function doInsertImage(){
    Editor.focus();
    doc.execCommand('InsertImage','xxx');
    }
    function doInsertInputButton(){
    Editor.focus();
    doc.execCommand('InsertInputButton');
    }
    function doInsertHorizontalRule(){
    Editor.focus();
    doc.execCommand('InsertHorizontalRule');
    }
    function doInsertInputCheckbox(){
    Editor.focus();
    doc.execCommand('InsertInputCheckbox');
    }
    function doInsertInputRadio(){
    Editor.focus();
    doc.execCommand('InsertInputRadio');
    }
    function doInsertInputText(){
    Editor.focus();
    doc.execCommand('InsertInputText');
    }
    function doInsertInputPassword(){
    Editor.focus();
    doc.execCommand('InsertInputPassword');
    }
    function doInsertInputSubmit(){
    Editor.focus();
    doc.execCommand('InsertInputSubmit');
    ShowMessage();
    }
    function doInsertInputReset(){
    Editor.focus();
    doc.execCommand('InsertInputReset');
    ShowMessage();
    }
    function doInsertMarquee(){
    Editor.focus();
    doc.execCommand('InsertMarquee');
    ShowMessage();
    }
    function doInsertSelectDropdown(){
    Editor.focus();
    doc.execCommand('InsertSelectDropdown');
    }
    function doInsertTextArea(){
    Editor.focus();
    doc.execCommand('InsertTextArea');
    }
    function doPrint(){
    doc.execCommand('Print');
    Editor.focus();
    }
    function doSaveAs(){
    doc.execCommand('SaveAs',0,"未命名");
    Editor.focus();
    }
    function doOpen(){
    doc.execCommand('Open');
    Editor.focus();
    }
    function EditResource(){
    Preview.value=doc.body.innerHTML;
    return false;
    }
    function ClearAll(){
    doc.body.innerHTML='';
    Preview.value='';
    return false;
    }
    function SeePreview(){
    doc.body.innerHTML=Preview.value;
    return false;
    }
    function AutoPreview(){
    if(vx.checked){
    SeePreview();
    }
    }
    function EditMode(){
    doc.designMode = "On";
    window.setTimeout('SeePreview()',100);
    Preview.focus();
    }
    function PreviewMode(){
    doc.designMode = "Off";
    window.setTimeout('SeePreview()',100);
    Preview.focus();
    }
    function ShowMessage(){
    alert("请按两下物件编辑内容");
    }
    </script>
    </head>
    <body bgcolor=#e0e0e0 OnKeyUP="AutoPreview();">
    <center>
    <table cellpadding=0 cellspacing=1><tr>
    <td><img src=editor_h.gif></td>
    <td><div title="核取方块" onclick="doInsertInputCheckbox();" onmouseover="BtnOver(this);" onmouseout="BtnOut(this);" onmousedown="BtnClick(this);" onmouseup="BtnOver(this);"><img src=editor_f28.gif></div></td>
    <td><div title="点选圆" onclick="doInsertInputRadio();" onmouseover="BtnOver(this);" onmouseout="BtnOut(this);" onmousedown="BtnClick(this);" onmouseup="BtnOver(this);"><img src=editor_f29.gif></div></td>
    <td><div title="文字输入" onclick="doInsertInputText();" onmouseover="BtnOver(this);" onmouseout="BtnOut(this);" onmousedown="BtnClick(this);" onmouseup="BtnOver(this);"><img src=editor_f30.gif></div></td>
    <td><div title="密码输入" onclick="doInsertInputPassword();" onmouseover="BtnOver(this);" onmouseout="BtnOut(this);" onmousedown="BtnClick(this);" onmouseup="BtnOver(this);"><img src=editor_f31.gif></div></td>
    <td><div title="选单方块" onclick="doInsertSelectDropdown();" onmouseover="BtnOver(this);" onmouseout="BtnOut(this);" onmousedown="BtnClick(this);" onmouseup="BtnOver(this);"><img src=editor_f32.gif></div></td>
    <td><div title="文字方块" onclick="doInsertTextArea();" onmouseover="BtnOver(this);" onmouseout="BtnOut(this);" onmousedown="BtnClick(this);" onmouseup="BtnOver(this);"><img src=editor_f33.gif></div></td>
    <td><img src=editor_s.gif></td>
    <td><div title="自订按钮" onclick="doInsertInputButton();" onmouseover="BtnOver(this);" onmouseout="BtnOut(this);" onmousedown="BtnClick(this);" onmouseup="BtnOver(this);"><img src=editor_f34.gif></div></td>
    <td><div title="送出按钮" onclick="doInsertInputSubmit();" onmouseover="BtnOver(this);" onmouseout="BtnOut(this);" onmousedown="BtnClick(this);" onmouseup="BtnOver(this);"><img src=editor_f35.gif></div></td>
    <td><div title="重设按钮" onclick="doInsertInputReset();" onmouseover="BtnOver(this);" onmouseout="BtnOut(this);" onmousedown="BtnClick(this);" onmouseup="BtnOver(this);"><img src=editor_f36.gif></div></td>
    </tr></table></td></tr>
    <tr><td bgcolor=#d9cec4><table cellpadding=0 cellspacing=1><tr>
    <td><img src=editor_h.gif></td>
    <td><input title="编辑模式" type=radio name=vm onclick="EditMode();" checked></td><td><div title="编辑模式"><img src=editor_e.gif></div></td><td>&nbsp;</td>
    <td><input title="预览模式" type=radio name=vm onclick="PreviewMode();"></td><td><div title="预览模式"><img src=editor_p.gif></div></td>
    </tr></table></td></tr>
    <tr><td><iframe id="Editor" marginwidth=1 scrolling="auto" style="height:150px;width:100%;background-color:white;"></iframe></td></tr>
    <tr><td bgcolor=#d9cec4><table cellpadding=0 cellspacing=1><tr>
    <td><img src=editor_h.gif></td>
    <td><button class=function onclick="EditResource();Preview.focus();">编辑原始码</button></td>
    <td><button class=function onclick="ClearAll();Preview.focus();">全部清除</button></td>
    <td><button class=function onclick="SeePreview();Preview.focus();">结果预览</button></td>
    <td><img src=editor_s.gif></td>
    <td><input title="自动预览" type=checkbox name=vx onclick="AutoPreview();Preview.focus();" checked></td><td><div title="自动预览"><img src=editor_a.gif></div></td>
    </tr></table></td></tr>
    <tr><td><textarea id=Preview style="height:150px;width:100%;background-color:#ffffff;overflow=auto;"></textarea></td></tr>
    </table>
    </center>
    <script>
    var doc;
    doc=document.frames.Editor.document;
    doc.designMode = "On";
    window.setTimeout('Editor.focus()',100);
    </script>
    </body>
    </html>
      

  2.   

    问题是,
    function doInsertInputRadio(){
    Editor.focus();
    doc.execCommand('InsertInputRadio');
    doc.execCommand('InsertInputRadio');
    doc.execCommand('InsertInputRadio');
    doc.execCommand('InsertInputRadio');
    }这样执行,只能产生1个radio!我需要4个,如何办?
    因为目的是编辑试卷里的选择题,一次性同时产生四个选项;否则按4下"插入radio"按钮,操作太麻烦了。
      

  3.   

    每个RADIO的NAME属性不能一样,改一改*****
    打工好辛苦
    *****
    钞票好难赚
    *****
    编程好伤神
    *****
    光阴好易混
    *****
      

  4.   

    doc.insertAdjacentHTML("<input type='checkbox'/><input type='checkbox'/><input type='checkbox'/><input type='checkbox'/>...");想插多少就多少。