我有一个网页,里面的javascript在IE7上运行得很好。现在我们必须使用IE9,但页面无法工作。在页面上,我们使用javascipt将datakey作为cookie存储在datagrid中。然而,javascript获取datakey的值是未定义的。有人能告诉我怎么解决这个问题吗?提前谢谢。
数据网格有一个aspx页面:
<asp:datagrid id="dgrdLocationWeeks" runat="server" ShowFooter="True"
autogeneratecolumns="false" cssclass="dgrid2" cellpadding="5" width="550"
datakeyfield="LocationId"> 在资源视图中有一行数据网格。
<input name="dgrdLocationWeeks$ctl02$chkHideLocation" type="checkbox"
id="dgrdLocationWeeks_ctl02_chkHideLocation" locationID="7" />我获取datakey值的javascript是这样的:
strHideLocations += document.getElementById(ctrlPrefixName + rowIndex +
ctrlSuffixName).locationID我知道我可以将数据键放入列中,但在这样的页面中有太多的数据网格。我认为在javascript上修复它会更好。
发布于 2013-02-19 09:38:08
尝试以下方法,以获得对浏览器更友好的方法:
var elem = document.getElementById(elemId); //in your case: ctrlPrefixName + rowIndex + ctrlSuffixName
var locID = elem.locationID || elem.getAttribute('locationID');
//alert(locID);https://stackoverflow.com/questions/14947773
复制相似问题