我想创建iframe的时候显示title。这是我部分代码:
function createIframe(){
isCreateIframe = true;
var frm = document.createElement("iframe");
         frm.title = "iframe相关信息";
frm.id = 'ifrm';
frm.name = 'ifrm';
frm.style.position = 'absolute';
frm.style.width = 450;
frm.style.height = 150;
frm.style.left = document.body.scrollLeft + event.clientX + 50;
frm.style.top = document.body.scrollTop + event.clientY - 180;
frm.style.display = 'none';
document.body.appendChild(frm);
}
不知道什么原因怎么不显示tilte的内容。有什么方法实现吗?请大家帮我解决这个问题。

解决方案 »

  1.   

    我在框架中显示页面,为什么页面上也不显示title呢?
    function htmlEditor(){
    var frm = document.getElementById("ifrm");
    frm.style.display = '';
    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 += '<TITLE>AAAA</TITLE>';
    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><font class=clsLabelFont ><B><B>'+parCodeLabel+'</B></B></font></TD>';
    iframeTextContent += '<TD><input type="text" id="tbMstParamCode" name="tbMstParamCode" style="WIDTH:  100;" class="clsReadOnlyBox" maxlength= 10 readOnly  /></TD>';
    iframeTextContent += '</TR>';
    if(frmDataEntry.tbMstisAllowAdd(RowID).value!=2){
    iframeTextContent += '<TR>';
    iframeTextContent += '<TD><font class=clsLabelFont ><B><B>'+parValueLabel+'</B></B></font></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><font class=clsLabelFont ><B><B>Description&nbsp;</B></B></font></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><IMG  id="btnfrmCanel" name="btnfrmCanel" src="/abPortal/Setting/GWG/btnImages/USA/Cancel_o.gif" style="cursor:pointer ;"  border=0 alt="Close the curent Page"></TD>';
    iframeTextContent += '</TR>';
    iframeTextContent += '</TABLE>';
    iframeTextContent += '</Form>';
    iframeTextContent += '</BODY>';
    iframeTextContent += '</html>';
    frm.contentWindow.document.designMode = 'off';
        frm.contentWindow.document.open();
    frm.contentWindow.document.write(iframeTextContent);
    frm.contentWindow.document.close();
    frm.contentWindow.document.getElementById("tbMstParamCode").value = frmDataEntry.tbMstParamCode[RowID].value;
    var objSave =frm.contentWindow.document.getElementById("btnfrmSave");
    objSave.attachEvent("onclick",function(){beforSave(RowID,frm)});
    var objCanel = frm.contentWindow.document.getElementById("btnfrmCanel");
    objCanel.onclick = function(){
    frm.style.display = 'none';
    };
    }
    我动态创建页面,但加载页面中应该显示title中的内容'AAAA';
    没有任何效果,可以实现吗?又如何实现呢?谢谢你的指点。
      

  2.   

    浏览器只会显示主页面的title
    LZ是要改主页面的title就可以了
      

  3.   

    可以在iframe中添加边框吗?就像打开一个页面那样,
    但一定是js动态创建的iframe.有哪位指点下。谢谢了。
    很急!
      

  4.   

    怎么实现呢?我的意思就在浮动页面显示title中的内容就可以了。你相关代码吗?谢谢你了。
      

  5.   

    我是想实现浮动页面,加了div,浮动页面就没有什么用途了。
      

  6.   

    能从框架外改变iframe内的内容吗?
      

  7.   

    我拖动iframe实现的问题解决了,但觉得拖动不太流畅,后来由两个div加一个iframe实现了拖动加
    浮动页面。以下是我的示例可以运行,
    <!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=gb2312" />
    <title>Untitled Document</title>
    <script>
    function createIframe(){
    var objDiv = document.createElement("DIV");
    objDiv.id = "div1";
    objDiv.name = "div1";
    objDiv.style.width = "480px";
    objDiv.style.height = "200px";
    objDiv.style.left = document.body.scrollLeft + event.clientX + 50;
    objDiv.style.top = document.body.scrollTop + event.clientY - 180;
    objDiv.style.position = "absolute";
    objDiv.innerHTML = '<div id="drag" style="position:absolute;height:20px;width:100%;z-index:10001;top:0; background-color:#0033FF;cursor:move ;"></div>';
    objDiv.style.border = "solid #0033FF  3px;";
    objDiv.style.display = 'none';

    var frm = document.createElement("iframe");
    frm.id = "ifrm";
    frm.name = "ifrm";
    frm.style.position = "absolute";
    frm.style.width = "100%";
    frm.style.height = 180;
    frm.style.top = 20;
    frm.style.display = '';
    frm.frameborder=0;
    objDiv.appendChild(frm);
      document.body.appendChild(objDiv);
    var objDrag = document.getElementById("drag");
    var drag = false;
    objDrag.attachEvent("onmousedown",startDrag);
    function startDrag(){
    if(event.button == 1 && event.srcElement.tagName.toUpperCase() =="DIV"){
    objDrag.setCapture();
    objDrag.style.background = "#0000CC";
    drag = true;
    }
    };
    objDrag.attachEvent("onmousemove",Drag);
    function Drag(){
    if(drag){
    var oldwin = objDrag.parentNode;
    oldwin.style.left = event.clientX - 100;
    oldwin.style.top = event.clientY - 10;
    }
    };
    objDrag.attachEvent("onmouseup",stopDrag);
    function stopDrag(){
    objDrag.style.background = "#0033FF";
    objDrag.releaseCapture();
    drag = false;
    };
    }
    function htmlEditor(){
    var frm = document.getElementById("ifrm");
    var objDiv = document.getElementById("div1");
    objDiv.style.display = '';
    var iframeTextContent = '';
    iframeTextContent += '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">';
    iframeTextContent += '<html xmlns="http://www.w3.org/1999/xhtml">';
        iframeTextContent += '<head>';
        iframeTextContent += '<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />';
        iframeTextContent += '</head>';
    iframeTextContent += '<body>';
    iframeTextContent += '<table>';
    iframeTextContent += '<tr>';
    iframeTextContent += '<td>Name</td>';
        iframeTextContent += '<td><input type="text" value="" /></td>';
        iframeTextContent += '</tr>';
        iframeTextContent += '<tr>';
        iframeTextContent += '<td>Email</td>';
        iframeTextContent += '<td><input type="text" value="" /></td>';
        iframeTextContent += '</tr>';
        iframeTextContent += '<tr>';
        iframeTextContent += '<td><input type="button" id="btGo" value="Go" /></td>';
        iframeTextContent += '</tr>';
        iframeTextContent += '</table>';
        iframeTextContent += '</body>';
        iframeTextContent += '</html>';
    frm.contentWindow.document.designMode = 'off';
        frm.contentWindow.document.open();
        frm.contentWindow.document.write(iframeTextContent);
        frm.contentWindow.document.close();

    var objGo = frm.contentWindow.document.getElementById("btGo");
        objGo.attachEvent("onclick",function(){HideIframe(objDiv);});
    }

    function HideIframe(objDiv){
       objDiv.style.display = 'none';
      }
    </script>
    </head><body onload="createIframe()">
    <input type="button" id="tt" name="tt" value="Click" onclick="htmlEditor()" />
    </body>
    </html>