需要错误对象 [英] error object required
本文介绍了需要错误对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我将使用以下代码更改标签
lblBtkName
文本值。
但是提供错误需要对象
提前thx
if (document.getElementById( < span class =code-string> _ ctl0_DOC_TITLE)。innerHTML == MOC){
document.getElementById( MOCCheatSheet)。style。 display = ;
var lblBtkName = document.getElementById( _ctl1_BTK_NAME跨度>);
var lblBtkDesc = document.getElementById( _ ctl1_BTK_DESCRIPTION跨度>);
var lang = GetCookie( SmartLang 跨度>);
if (lang.toLowerCase()== de-de)
{
if (lblBtkName.innerHTML.toLowerCase()== Analyze der Auswirkungen(EMPF)){
lblBtkName.innerHTML = 分析Auswirkungen(EMPF)(ACHGDJF);
}
}
}
解决方案
正常原因是getElementById方法无法找到具有该名称的控件。
所以添加一些检查到lblBtkName
以确保它不为空 - 如果是,请检查控件名称的拼写,并在正确的页面上使用此代码!
和Pheonyx是对的:你没有小写字母与小写字母一起检查......
你使用的是哪个版本的.Net?
注意只有.Net 3.0及以上版本才支持var
[ ^ ]。
Hi all,
M going to change label
lblBtkName
text value using below code.
but gives error "object required"
thx in advance.
if (document.getElementById("_ctl0_DOC_TITLE").innerHTML == "MOC") {
document.getElementById("MOCCheatSheet").style.display = "";
var lblBtkName = document.getElementById("_ctl1_BTK_NAME");
var lblBtkDesc = document.getElementById("_ctl1_BTK_DESCRIPTION");
var lang = GetCookie("SmartLang");
if (lang.toLowerCase() == "de-de")
{
if (lblBtkName.innerHTML.toLowerCase() == "Analyse der Auswirkungen(EMPF)") {
lblBtkName.innerHTML = "Analyse der Auswirkungen(EMPF)(ACHGDJF)";
}
}
}
解决方案
The normal reason for this is that the getElementById methods can't find a control with that name.
So add some checking tolblBtkName
to make sure it isn't null - and if it is, check the spelling of the control name and that this code is being used on the correct page!
And Pheonyx is right: you aren't checking lowercase against lowercase...
Which version of .Net are you using?
Note thatvar
is only supported in .Net 3.0 and above[^].
这篇关于需要错误对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文