我的问题是这样的,我是用iframe创建页面的,不是用<iframe scr= "a.html" ></iframe>这种方式加载页面的,
现在的问题是,我创建页面中如果不用到设计模式的话,再次打开页面为null,我用了设计模式在iframe中每个
地方都可以编辑,这样很不好,也不知道怎么去解决,我只希望的是我创建<input type="text" value="">中可以编辑。
其它的地方不要编辑。如何实现呢?
这是我部分代码:
         var frm = document.getElementById("iframe");
var iframeTextContent = '';
iframeTextContent += '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">';
iframeTextContent += '<html>';
iframeTextContent += '<HEAD>';
iframeTextContent += '<LINK href="/abPortal/Setting/GWG/abPortal.css" rel=STYLESHEET type="text/css">';
iframeTextContent += '<META http-equiv=Content-Type content="text/html; charset=utf-8">';
iframeTextContent += '<META content="MSHTML 5.00.3103.1000" name=GENERATOR>';
iframeTextContent += '</HEAD>';
iframeTextContent += '<BODY class="clsNorBody">';
iframeTextContent += '<Form name=frmDataEntry method=Post validate="onchange" invalidColor="LightGoldenrodYellow" >';
iframeTextContent += '<TABLE  class="clsMasterTable"  align=left border=0  cellpadding=0 cellspacing=0 >';
iframeTextContent += '<TR>';
iframeTextContent += '<TD>Parameter&nbsp;Code&nbsp;</TD>';
iframeTextContent += '<TD><input type="text" id="tbMstParamCode" name="tbMstParamCode" style="WIDTH:  100;" class="clsReadOnlyBox" maxlength= 10 readOnly  /></TD>';
iframeTextContent += '</TR>';
iframeTextContent += '<TR>';
iframeTextContent += '<TD>Parameter&nbsp;Value&nbsp;</TD>';
iframeTextContent += '<TD><input type="text" id="tbMstParamValue" name="tbMstParamValue" style="WIDTH:  300;" maxlength= 50 class="clsInputBox"  required /></TD>';
iframeTextContent += '</TR>';
iframeTextContent += '<TR>';
iframeTextContent += '<TD>Description&nbsp;</TD>';
iframeTextContent += '<TD><input type="text" id="tbMstDescription" name="tbMstDescription" style="WIDTH:  300;" maxlength= 50 class="clsInputBox" required  /></TD>';
iframeTextContent += '</TR>';
iframeTextContent += '<TR>';
iframeTextContent += '<TD><IMG  id="btnfrmSave" name="btnfrmSave" src="/abPortal/Setting/GWG/btnImages/USA/floppy.gif" style="cursor:pointer ;"  border=0 alt="Save the curent document"></TD>';
iframeTextContent += '<TD></TD>';
iframeTextContent += '</TR>';
iframeTextContent += '</TABLE>';
iframeTextContent += '</Form>';
iframeTextContent += '</BODY>';
iframeTextContent += '</html>';
frm.contentWindow.document.designMode = 'on';
frm.contentWindow.document.open();
frm.contentWindow.document.write(iframeTextContent);
frm.contentWindow.document.close();
如果我不写frm.contentWindow.document.designMode = 'on';
frm.contentWindow.document.open();
frm.contentWindow.document.close();的话,变成不可编辑,我想要的就是这个效果,可以重新打开的时候却是null页面。
怎么解决呢?有点急,希望大家能帮我解决这个问题。谢谢了!

解决方案 »

  1.   

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>无标题文档</title>
    <link rel="stylesheet" type="text/css" href="common.css">
    <script language="javascript" type="text/javascript" src="scripts/jquery-1.2.1.js"></script>
    <script language="javascript" type="text/javascript">
    $(function(){
    var text = $('input[type=text]');
    $('#editBtn').click(function(){text.attr("disabled","");
    $('#mode span').html('编辑模式');});
    $('#outEditBtn').click(function(){text.attr("disabled","true");
    $('#mode span').html('浏览模式');}).click();
    });
    </script>
    </head><body>
    <fieldset style="padding-left:500px; font-size:34px;">
    <legend>DOMO表单</legend>
        <div>用户名:<input name="" type="text" value="AAA"/></div>
        <div>密 码: <input name="" type="text" value="AAA"/></div>
        <div>电 话: <input name="" type="text" value="AAA"/></div>
        <div>邮 编: <input name="" type="text" value="AAA"/></div>
        <div>地 址:  <input name="" type="text" value="AAA"/></div>
        <div id="mode">
         当前模式:<span></span>
         <input name="" type="button" id="editBtn" value="进入编辑模式" />
         <input name="" type="button" id="outEditBtn" value="退出编辑模式" />
        </div>
    </fieldset>
    </body>
    </html>
    不知道问题根本所在,但是jquery里面倒是提供了一个很好的解决方法,参考一下吧
      

  2.   

    有哪位高手帮我解决这个问题呢?再次打开iframe页面的时候是空页面,如果解决。