当我调用JavaScript函数来显示一个模式窗口我收到此错误:的JavaScript错误:Microsoft JScript运行时错误:“的document.getElementById(...)”为空或不是对象
Microsoft JScript runtime error: 'document.getElementById(...)' is null or not an object
代码块为:
else if (action=="officeview") {
document.getElementById("OfficeContent").src="ChangeView.aspx";
ShowFeatureModal('AppView','OfficeContent')
对象是这种情况,确实存在。
错误发生在:document.getElementById
一行。 还有什么可能导致错误?
更新:
Index.aspx的呼吁,位于sysUtilities.js文件中的JavaScript函数。源文件还没有单独页面(ChangeView.aspx)
'document.getElementById'返回'null'如果元素未找到,并且不允许访问'null'的'.src'。你在哪里使用这段代码? –
如果你看看你的页面的源代码(在浏览器中),你能找到一个id为“OfficeContent”的HTML元素吗? – M4N
@DigitalPlane不确定您的意思是“我在哪里使用此代码”它被用于客户端,调用模态窗口。用户单击一个超链接,并调用该代码块。 – DotNetRookie