如何用了<iframe >那还是得<iframe scr="xx.htm">关键是我一定要用到这个
iframe呀

解决方案 »

  1.   

    1.text_edit.htm添加代码如下
    <iframe name="target" style="WIDTH: 90%; border:1 #000000 solid;HEIGHT: 80%" tabindex=4 border=0 frameborder=0>
       </iframe> 
    <br>
    </div>
    </body>
    <script >
    targetDoc = document.frames.target.document;
    targetDoc.designMode = "On";
    target.focus();public_description=new Editorfunction Editor()
    {
      this.put_html=function(v){target.document.body.innerHTML=v};
      this.get_html=function(){return target.document.body.innerHTML};
      this.put_text=function(v){target.document.body.innerText=v};
      this.get_text=function(){return target.document.body.innerText};
    }
    </script>2.text.html就可以调用html和text了
    <object id="mess" name="mess"  data="text_edit.htm"  width="100%" height="90%" type="text/x-scriptlet" ></object>
    <input type=button onclick=alert(document.all.mess.html) value=html>
    <input type=button onclick=alert(document.all.mess.text) value=text>
      

  2.   

    比如说我在text_edit.htm中的iframe中输入了一个有id的span呢
    targetDoc = document.frames.target.document;
    targetDoc.designMode = "On";
    var newsObj = document.frames("target");
    newsObj.document.designMode ="On";
    newsObj.document.open();
    newsObj.document.write('<SPAN id=frmbt1 style="COLOR: red; ">通知</SPAN>');
    newsObj.document.write('<SPAN id=frmbt2 style="COLOR: red; ">通知人</SPAN>');现在我要在text.html中通过<input type=text name=text1 > 当它onblur时把值传给
    text_edit中的<span id=frmb1>而不是取得
    document.all.mess的整个text或是html呀
    秋水这样子你能看懂吗麻烦你再看看吧
      

  3.   

    1.text.htm
    <html><form name='abc'>
    <table width="640" border="1" cellspacing="0" cellpadding="0" align="center"  bordercolorlight="#000000" bordercolordark="#ffffff">
    <tr><td><table width="640" height="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="buttonface"  >
        <tr> 
          <td width="11%" height="30">标题:</td>
          <td width="89%" height="30"><input name="bt" type="text" id="bt" onblur='document.all.mess.doc.all.frmbt1.innerText="标题:"+value'></td>
        </tr>
        <tr> 
          <td height="30">建议人:</td>
          <td><input name="jyr" type="text" id="jyr" onblur='document.all.mess.doc.all.frmbt2.innerText="建议人:"+value'></td>
        </tr>
        <tr> 
          <td height="700" colspan="2"><object id="mess" name="mess"  data="text_edit.htm"  width="100%" height="90%" type="text/x-scriptlet" >
            </object></td>
        </tr>
      </table></td><tr></table>
      <input type=hidden name=doctext>
    <input type=button name=submit value="查看"onclick="javascript:aaaa();">
    </form>
    <script>
    function aaaa()
    {
    abc.doctext.value=abc.mess.html;
    alert(abc.doctext.value);
    }</script>2.text_edit.html<iframe name="target" style="WIDTH: 90%; border:1 #000000 solid;HEIGHT: 80%" tabindex=4 border=0 frameborder=0>
       </iframe> 
    <br>
    </div>
    </body>
    <script >targetDoc = target.document;
    targetDoc.designMode = "On";
    targetDoc.open();
    targetDoc.write('<SPAN id=frmbt1 style="COLOR: red; ">标题:</SPAN><br>');
    targetDoc.write('<SPAN id=frmbt2 style="COLOR: red; ">建议人:</SPAN>');
    targetDoc.close();
    target.focus();
    public_description=new Editorfunction Editor()
    {
      this.put_html=function(v){target.document.body.innerHTML=v};
      this.get_html=function(){return target.document.body.innerHTML};
      this.put_text=function(v){target.document.body.innerText=v};
      this.get_text=function(){return target.document.body.innerText};
      this.get_doc=function(){return target.document};
    }
    </script>
      

  4.   

    给你个HTML Editor的例子吧
    <STYLE>
    DIV.btn {BORDER-RIGHT: #d9cec4 1px solid; BORDER-TOP: #d9cec4 1px solid; BACKGROUND: #d9cec4; BORDER-LEFT: #d9cec4 1px solid; WIDTH: 24px; CURSOR: default; BORDER-BOTTOM: #d9cec4 1px solid; HEIGHT: 20px; TEXT-ALIGN: center; borderColor: #ffffff}
    </STYLE>
    <script language="JavaScript" src="/HTMLEDITOR/SCRIPT/HTMLEDITOR.JS">
    </script>
    <table align="center" cellSpacing="0" borderColorDark="#efece8" cellPadding="0" width="100%" borderColorLight="#888070" border="1">
      <tr>

        <td bgColor="#d9cec4" height=20> 
          <table cellSpacing="0" cellPadding="0" border="0">
            <tr> 
              <td><IMG height=20 src="/HTMLEDITOR/IMAGE/editor_h.gif" width=6></td>
              <td> 
                <div class=btn onmousedown=BtnClick(this); onmouseup="BtnOver(this);" onmouseover="BtnOver(this);" title="剪切" onclick="doCut();" onmouseout="BtnOut(this);" > 
                  <IMG height=20 src="/HTMLEDITOR/IMAGE/editor_f03.gif" width=19></div>
              </td>
              <td> 
                <div class=btn onmousedown=BtnClick(this); onmouseup="BtnOver(this);" onmouseover="BtnOver(this);" title="复制" onclick="doCopy();" onmouseout="BtnOut(this);"> 
                  <IMG height=20 src="/HTMLEDITOR/IMAGE/editor_f04.gif" width=19></div>
              </td>
              <td> 
                <div class=btn onmousedown=BtnClick(this); onmouseup="BtnOver(this);" onmouseover="BtnOver(this);" title="粘贴" onclick="doPaste();" onmouseout="BtnOut(this);"> 
                  <IMG height=20 src="/HTMLEDITOR/IMAGE/editor_f05.gif" width=19></div>
              </td>
              <td> 
                <div class=btn onmousedown=BtnClick(this); onmouseup="BtnOver(this);" onmouseover="BtnOver(this);" title="删除" onclick="doDelete();" onmouseout="BtnOut(this);"> 
                  <IMG height=20 src="/HTMLEDITOR/IMAGE/editor_f06.gif" width=19></div>
              </td>
              <td> 
                <div class=btn onmousedown=BtnClick(this); onmouseup="BtnOver(this);" onmouseover="BtnOver(this);" title="还原" onclick="doUndo();" onmouseout="BtnOut(this);"> 
                  <IMG height=20 src="/HTMLEDITOR/IMAGE/editor_f07.gif" width=19></div>
              </td>
              <td> 
                <div class=btn onmousedown=BtnClick(this); onmouseup="BtnOver(this);" onmouseover="BtnOver(this);" title="居左对齐" onclick="doJustifyLeft();" onmouseout="BtnOut(this);"> 
                  <IMG height=20 src="/HTMLEDITOR/IMAGE/editor_f16.gif" width=19></div>
              </td>
              <td> 
                <div class=btn onmousedown=BtnClick(this); onmouseup="BtnOver(this);" onmouseover="BtnOver(this);" title="居中对齐" onclick="doJustifyCenter();" onmouseout="BtnOut(this);"> 
                  <IMG height=20 src="/HTMLEDITOR/IMAGE/editor_f17.gif" width=19></div>
              </td>
              <td> 
                <div class=btn onmousedown=BtnClick(this); onmouseup="BtnOver(this);" onmouseover="BtnOver(this);" title="居右对齐" onclick="doJustifyRight();" onmouseout="BtnOut(this);"> 
                  <IMG height=20 src="/HTMLEDITOR/IMAGE/editor_f18.gif" width=19></div>
              </td>
              <td> 
                <div class=btn onmousedown=BtnClick(this); onmouseup="BtnOver(this);" onmouseover="BtnOver(this);" title="增加缩进" onclick="doIndent();" onmouseout="BtnOut(this);"> 
                  <IMG height=20 src="/HTMLEDITOR/IMAGE/editor_f19.gif" width=19></div>
              </td>
              <td> 
                <div class=btn onmousedown=BtnClick(this); onmouseup="BtnOver(this);" onmouseover="BtnOver(this);" title="减少缩进" onclick="doOutdent();" onmouseout="BtnOut(this);"> 
                  <IMG height=20 src="/HTMLEDITOR/IMAGE/editor_f20.gif" width=19></div>
              </td>
              <td> 
                <div class=btn onmousedown=BtnClick(this); onmouseup="BtnOver(this);" onmouseover="BtnOver(this);" title="數字標題" onclick="doInsertOrderedList();" onmouseout="BtnOut(this);"> 
                  <IMG height=20 src="/HTMLEDITOR/IMAGE/editor_f21.gif" width=19></div>
              </td>
              <td> 
                <div class=btn onmousedown=BtnClick(this); onmouseup="BtnOver(this);" onmouseover="BtnOver(this);" title="無數字標題" onclick="doInsertUnorderedList();" onmouseout="BtnOut(this);"> 
                  <IMG height=20 src="/HTMLEDITOR/IMAGE/editor_f22.gif" width=19></div>
              </td>
              <td> 
                <div class=btn onmousedown=BtnClick(this); onmouseup="BtnOver(this);" onmouseover="BtnOver(this);" title="插入分隔線" onclick="doInsertHorizontalRule();" onmouseout="BtnOut(this);"> 
                  <IMG height=20 src="/HTMLEDITOR/IMAGE/editor_f23.gif" width=19></div>
              </td>
      

  5.   


              <td> 
                <div class=btn onmousedown=BtnClick(this); onmouseup="BtnOver(this);" onmouseover="BtnOver(this);" title="插入表格" onclick="doInsertTable();" onmouseout="BtnOut(this);"> 
                  <IMG height=20 src="/HTMLEDITOR/IMAGE/editor_f24.gif" width=19></div>
              </td>
              <td> 
                <div class=btn onmousedown=BtnClick(this); onmouseup="BtnOver(this);" onmouseover="BtnOver(this);" title="插入連結" onclick="doCreateLink();" onmouseout="BtnOut(this);"> 
                  <IMG height=20 src="/HTMLEDITOR/IMAGE/editor_f25.gif" width=19></div>
              </td>
              <td> 
                <div class=btn onmousedown=BtnClick(this); onmouseup="BtnOver(this);" onmouseover="BtnOver(this);" title="插入圖片" onclick="doInsertImage();" onmouseout="BtnOut(this);"> 
                  <IMG height=20 src="/HTMLEDITOR/IMAGE/editor_f26.gif" width=19></div>
              </td>
              <td> 
                <div class=btn onmousedown=BtnClick(this); onmouseup="BtnOver(this);" onmouseover="BtnOver(this);" title="跑馬燈" onclick="doInsertMarquee();" onmouseout="BtnOut(this);"> 
                  <IMG height=20 src="/HTMLEDITOR/IMAGE/editor_f27.gif" width=19></div>
              </td>
            </tr>
          </table>

        </td>
    </tr>
    <tr>
    <td bgColor="#d9cec4" height=20>
    <table cellSpacing="0" cellPadding="0" border="0">
    <tr>
    <td><IMG height=20 src="/HTMLEDITOR/IMAGE/editor_h.gif" width=6></td>
    <td><select onchange="doFontName(this[this.selectedIndex].value);this.selectedIndex=0;">
    <option value ="" selected>字型</option>
    <option value="宋体">宋体</option>
    <option value="黑体">黑体</option>
    <option value="仿宋_GB2312">仿宋</option>
    <option value="隶书">隶书</option>
    <option value="楷体_GB2312">楷体</option>
    <option value="arial">arial</option>
    <option value="Times New Roman">Times New Roman</option>
    <option value="Verdana">Verdana</option>
    </select>
    </td>
    <td><select onchange="doFontSize(this[this.selectedIndex].value);this.selectedIndex=0;">
    <option value ="" selected>大小
    <option value="1">1
    <option value="2">2
    <option value="3">3(預設)
    <option value="4">4
    <option value="5">5
    <option value="6">6
    <option value="7">7</option>
    </select>
    </td>
              <td>

                <div class=btn onmousedown=BtnClick(this); onmouseup="BtnOver(this);" onmouseover="BtnOver(this);" title="粗體字" onclick="doBold();" onmouseout="BtnOut(this);"> 
                  <IMG height=20 src="/HTMLEDITOR/IMAGE/editor_f08.gif" width=19></div>
    </td>
    <td>

                <div class=btn onmousedown=BtnClick(this); onmouseup="BtnOver(this);" onmouseover="BtnOver(this);" title="斜體字" onclick="doItalic();" onmouseout="BtnOut(this);"> 
                  <IMG height=20 src="/HTMLEDITOR/IMAGE/editor_f09.gif" width=19></div>
    </td>
    <td>

                <div class=btn onmousedown=BtnClick(this); onmouseup="BtnOver(this);" onmouseover="BtnOver(this);" title="劃底線" onclick="doUnderline();" onmouseout="BtnOut(this);"> 
                  <IMG height=18 src="/HTMLEDITOR/IMAGE/editor_f10.gif" width=19></div>
    </td>
    <td>

                <div class=btn onmousedown=BtnClick(this); onmouseup="BtnOver(this);" onmouseover="BtnOver(this);" title="刪除線" onclick="doStrikeThrough();" onmouseout="BtnOut(this);"> 
                  <IMG height=18 src="/HTMLEDITOR/IMAGE/editor_f11.gif" width=19></div>
    </td>

              <td>

                <div class=btn onmousedown=BtnClick(this); onmouseup="BtnOver(this);" onmouseover="BtnOver(this);" title="上標字" onclick="doSuperscript();" onmouseout="BtnOut(this);"> 
                  <IMG height=18 src="/HTMLEDITOR/IMAGE/editor_f12.gif" width=19></div>
    </td>
    <td>

                <div class=btn onmousedown=BtnClick(this); onmouseup="BtnOver(this);" onmouseover="BtnOver(this);" title="下標字" onclick="doSubscript();" onmouseout="BtnOut(this);"> 
                  <IMG height=18 src="/HTMLEDITOR/IMAGE/editor_f13.gif" width=19></div>
    </td>

              <td>&nbsp;</td>
    <td>

                <div class=btn onmousedown=BtnClick(this); onmouseup="BtnOver(this);" onmouseover="BtnOver(this);" title="文字顏色" onclick="doForeColor();" onmouseout="BtnOut(this);"> 
                  <IMG height=20 src="/HTMLEDITOR/IMAGE/editor_f14.gif" width=19></div>
    </td>
    <td>

                <div class=btn onmousedown=BtnClick(this); onmouseup="BtnOver(this);" onmouseover="BtnOver(this);" title="背景顏色" onclick="doBackColor();" onmouseout="BtnOut(this);"> 
                  <IMG height=20 src="/HTMLEDITOR/IMAGE/editor_f15.gif" width=19></div>
    </td>
    </tr>
    </table>
    </td>
    </tr>
    <tr><td height=><iframe id="Editor" style="WIDTH:100%;HEIGHT:164px;BACKGROUND-COLOR:white" marginWidth="1" src="about:blank"></iframe></td></tr>
    </table>
    <script>
    var doc;
    doc=document.frames.Editor.document;
    doc.designMode = "On";
    window.setTimeout('Editor.focus()',100);
    </script>
      

  6.   

    省掉了表格选项和颜色拾取器的代码HTMLEDITOR.JSfunction 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 doCut(){
    doc.execCommand('Cut');
    Editor.focus();
    }
    function doCopy(){
    doc.execCommand('Copy');
    Editor.focus();
    }
    function doPaste(){
    doc.execCommand('Paste');
    Editor.focus();
    }
    function doUndo(){
    doc.execCommand('Undo');
    Editor.focus();
    }
    function doDelete(){
    doc.execCommand('Delete');
    Editor.focus();
    }
    function doFontName(fn){
    doc.execCommand('FontName', false, fn);
    Editor.focus();
    }
    function doFontSize(fs){
    doc.execCommand('FontSize', false, fs);
    Editor.focus();
    }
    function doBold(){
    doc.execCommand('Bold');
    Editor.focus();
    }
    function doItalic(){
    doc.execCommand('Italic');
    Editor.focus();
    }
    function doUnderline(){
    doc.execCommand('Underline');
    Editor.focus();
    }
    function doStrikeThrough(){
    doc.execCommand('StrikeThrough');
    Editor.focus();
    }
    function doSubscript(){
    doc.execCommand('Subscript');
    Editor.focus();
    }
    function doSuperscript(){
    doc.execCommand('Superscript');
    Editor.focus();
    }
    function doJustifyLeft(){
    doc.execCommand('JustifyLeft');
    Editor.focus();
    }
    function doJustifyRight(){
    doc.execCommand('JustifyRight');
    Editor.focus();
    }
    function doJustifyCenter(){
    doc.execCommand('JustifyCenter');
    Editor.focus();
    }
    function doIndent(){
    doc.execCommand('Indent');
    Editor.focus();
    }
    function doOutdent(){
    doc.execCommand('Outdent');
    Editor.focus();
    }
    function doForeColor(){
    var fcolor=showModalDialog("/HTMLEDITOR/PALETTE.HTM",false,"dialogWidth:106px;dialogHeight:126px;status:0;");
    doc.execCommand('ForeColor',false,fcolor);
    Editor.focus();
    }
    function doBackColor(){
    var bcolor=showModalDialog("/HTMLEDITOR/PALETTE.HTM",false,"dialogWidth:106px;dialogHeight:126px;status:0;");
    doc.execCommand('BackColor',false,bcolor);
    Editor.focus();
    }
    function doInsertTable(){
    var dotable=showModalDialog("/HTMLEDITOR/TABLEOPTION.HTM",false,"dialogWidth:200px;dialogHeight:156px;status:0;");
    if (dotable!=undefined){
    doc.body.innerHTML=doc.body.innerHTML+dotable;
    }else{
    return false;
    }
    Editor.focus();
    }
    function doInsertOrderedList(){
    doc.execCommand('InsertOrderedList');
    Editor.focus();
    }
    function doInsertUnorderedList(){
    doc.execCommand('InsertUnorderedList');
    Editor.focus();
    }
    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 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 ShowMessage(){
    alert("请双击对象编辑内容");
    }
      

  7.   

    佩服佩服:)解决了谢谢不过我还想问问你把这段代码解释下好吗我想求个明白,另这些资料的得到应该看那些书指点一下。:)
    public_description=new Editorfunction Editor()
    {
      this.put_html=function(v){target.document.body.innerHTML=v};
      this.get_html=function(){return target.document.body.innerHTML};
      this.put_text=function(v){target.document.body.innerText=v};
      this.get_text=function(){return target.document.body.innerText};
      this.get_doc=function(){return target.document};
    }