function sentIframeData(){
HtmlEdit.document.body.innerHTML=document.form1.TextBox1.value;
}
HtmlEdit是一个iframe的id,另一个页面也是这句话,但是没出错,为什么这个页面就出错呢,说HtmlEdit.document.body缺少对象.......有兴趣的可以看下面的完整代码前台<%@ Page Language="C#" AutoEventWireup="true" CodeFile="read.aspx.cs" Inherits="table_read"   ValidateRequest="false"%><!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 runat="server">
    <title>无标题页</title>
<script language="javascript" type="text/javascript">
// <!CDATA[function sentIframeData(){HtmlEdit.document.body.innerHTML=document.form1.TextBox1.value;
}// ]]>
</script>
</head>
<body>
    <form id="form1" runat="server">
    <div>        <div style="z-index: 102; left: 10px; width: 712px; position: absolute; top: 18px;
            height: 41px">
            <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="保存" Width="63px" />
            <asp:TextBox ID="TextBox1" runat="server" Width="487px"></asp:TextBox>
            <textarea id="TextArea1" cols="20" rows="2"></textarea></div>
        <br />
        <br />
        <br />
        <br />
        <br />
    <iframe id="ET" style="WIDTH: 100%; HEIGHT: 507px" marginwidth="0" marginheight="0"  scroll="auto">
</iframe>
    </div>
    </form>
</body>
</html>后台    kidduse kd = new kidduse();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            string myWriter = kd.getvalue<string>("select url from tt where id=10", 0);
            TextBox1.Text = myWriter;
            Page.RegisterStartupScript("ggg", "<script>sentIframeData();</script>");
        }
    }

解决方案 »

  1.   

    试试看
    document.getElementById("HtmlEdit").contentWindow.document.body.innerHTML=document.form1.TextBox1.value;
      

  2.   

    HtmlEdit真的存在么?我看到你的代码中不是只有个叫做ET的iframe……楼主好好检查你的页面
      

  3.   

    回2楼....不好意思,复制的时候改了点东西就是因为总是提示不存在,所以我才改了id为ET来试试...
      

  4.   

    回一楼...还是错Microsoft JScript 运行时错误: 'document.getElementById(...).contentWindow.document.body' 为空或不是对象
      

  5.   

    从document.getElementById("xx")开始 alert(),看到底哪个不存在document.getElementById("HtmlEdit")
    document.getElementById("HtmlEdit").contentWindow.
    document.getElementById("HtmlEdit").contentWindow.document
    document.getElementById("HtmlEdit").contentWindow.document.body
      

  6.   

    document.frames["HtmlEdit"].document.body
      

  7.   

    window.frames["HtmlEdit"].document.body.innerHTML=document.form1.TextBox1.value;
    或者
    document.getElementById("HtmlEdit").contentWindow.document.body.innerHTML=document.form1.TextBox1.value;
      

  8.   

    开卷有益了,调用frame对象时,要注意window 问题。
      

  9.   

    1.document.getElementById("HtmlEdit").document.body.innerHTML=document.form1.TextBox1.value;
    2.把HtmlEdit定义成name
      

  10.   

    应该是iframe还没有加载完的原因吧。
    尝试下在window.onload去调用sentIframeData();