document.body为null或不是对象
问题描述:
大家好,
我想在asp.net页面的加载时为iframe innerHTML属性分配一个值
asp.net页面具有MasterPage,
那是我的尝试:
Hi every body,
I want to assign a value to iframe innerHTML property on the load of the asp.net page
The asp.net page has MasterPage,
that is my try:
<asp:Content ID="Content1" ContentPlaceHolderID="OperatorContent" Runat="Server">
<iframe id="qwerty" >
</iframe>
<asp:hiddenfield id="hdhiddenfield" runat="server" />
<script type="text/javascript" >
var wer = document.getElementById('<%=hdhiddenfield.ClientID %>').value;
qwerty.document.body.innerHTML = qwe;
</script>
</asp:Content>
问题是:
qwerty.document.body为null或不是对象.
它看不到iframe控件
the problem is that:
qwerty.document.body is null or not an object.
it does not see the iframe control
答
尝试这样
将上面的脚本放在这样的一个函数中,然后调用该函数
try like this
put the above script in one function like this and call that function
<script type="text/javascript" >
function fnframe()
{
var wer = document.getElementById('<%=hdhiddenfield.ClientID %>').value;
qwerty.document.body.innerHTML = qwe;
}
</script>
试试这个
try this
<body onload="enablecontrols()">