代码片段:
var role=s[0].Role;// role contains string value
dijit.byId("editRole").attr("Value",getRoleByName(role));
function getRoleByName(role)
{
var roleVal;
alert(role);
switch(role)
{
case 'Basic User' :roleVal='1';break;
case 'Network Operator' :roleVal='3';break;
case 'System Administrator' :roleVal='5';break;
case 'Custom Level 1' :roleVal='11';break;
case 'Custom Level 2' : roleVal='12';break;
default: roleVal='1';break;
}
return roleVal;
}
当我尝试调用其中包含 switch 语句的 Javascript 方法时,我在 IE8 中遇到错误,但在 Firefox 中工作正常。
开发人员工具中的错误:
method Error executing: function(/*Event*/ e){
// summary:
// Handler when the user activates the button portion.
if(this._onClick(e) === false){ // returning nothing is same as true
e.preventDefault(); // needed for checkbox
} else if (this.type == "submit" && !this.focusNode.form){ // see if a nonform widget needs to be signalled
for(var node=this.domNode; node.parentNode/*#5935*/; node=node.parentNode){
var widget=dijit.byNode(node);
if(widget && typeof widget._onSubmit == "function"){
widget._onSubmit(e);
break;
}
}
}
}TypeError: Object doesn't support this property or method
谁能帮我这个?...如何克服这个问题?...