当我尝试关闭未打开的“ModalPopup”时,我的 javascript 会生成错误。 (Windows 7/Visual Studio 2012/asp.net c# css3 html5) 这是我的 Javascript ModalPopup 页面验证器:
<script type="text/javascript">
var $find= function (id) {
return document.getElementById(id);
};
setInterval(closePopup,1000);
function closePopup() {
if (!Page_IsValid) {
$find('mpeScheduleTask').hide();
}
}
</script>
打开时工作正常,未打开时生成错误...
错误:0x800a138f - JavaScript 运行时错误:无法获取未定义或 null 引用的属性“隐藏”
最佳答案
您可以先检查它是否存在:
function closePopup() {
if (!Page_IsValid) {
var mPopup = $find('mpeScheduleTask');
if (mPopup) mPopup.hide();
}
}
关于c# - 无法获取未定义或空引用的属性 'hide',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22410074/