繁体   English   中英

元素不存在的getelementbyid发生VBScript错误

[英]VBScript Erroring on getelementbyid for an element that doesn't exist

我有这段代码,当我= 9时出错。 对象T_009不存在于html表单中,但是我不明白为什么它会导致它出错,不是不是什么都不会检查吗? 我有几种使用vbscript的形式,但没有时间将它们全部转换,所以我坚持使用它。

dim i, obj_src, obj_dest
for i = 2 to 720
    set obj_src = document.getelementbyid("T_" & lpad(i,"0",3))
    set obj_dest = document.getelementbyid("s" & lpad(i,"0",3))
    if not obj_src is nothing and not obj_dest is nothing then
        obj_dest.innerhtml = obj_src.value
    end if
    set obj_src = nothing
    set obj_dest = nothing
Next

我需要启用兼容模式

<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7">

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM