gpt4 book ai didi

JavaScript 错误 : 'window.top.document.getElementById(...)' is null or not an object

转载 作者:数据小太阳 更新时间:2023-10-29 05:13:35 24 4
gpt4 key购买 nike

当我试图点击我的日历控件时出现 javascript 错误。

html代码为:

        <td align="left" style="width:50%;"><asp:Label runat="server" CssClass="TextFontBold" ID="lblStartDate" Text="Start Date:"></asp:Label>
<input type="text" class="TextBox" id="FromDate" runat="server"/><a href="javascript:ShowCalendar('FromDate1')"><img src="images/Calendar.png" border="0" /></a>
<iframe src="Calendar.aspx?DateTextID=FromDate" style="display:none; top: 0px; left: 0px; width:245px; height:164px" frameborder="0" scrolling="no" name="FromDate1" id="FromDate1"></iframe>&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;<asp:Label runat="server" CssClass="TextFontBold" ID="lblPromoStartTime" Text="Start Time:"></asp:Label>
</td>

当我点击日历控件中的日期时,这段代码在代码隐藏中执行:

Protected Sub Calendar1_SelectionChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Calendar1.SelectionChanged
Dim strjscript As String = "<script language=""javascript"" type=""text/javascript"">"
strjscript &= "window.top.document.getElementById('" & HttpContext.Current.Request.QueryString("DateTextID") & "').value = '" & Calendar1.SelectedDate & "';"
strjscript &= "window.top.document.getElementById('" & HttpContext.Current.Request.QueryString("DateTextID") & "1').style.display = 'none';"
strjscript = strjscript & "</script" & ">"
Literal1.Text = strjscript
End Sub

我收到的错误是'window.top.document.getElementById(...)' 为空或不是对象

我确实有一个名为 FromDate 的对象。
还有什么可能导致此错误?

最佳答案

尝试使用 window.parent.document.getElementById() 而不是 window.top.document.getElementById()

关于JavaScript 错误 : 'window.top.document.getElementById(...)' is null or not an object,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7353847/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com