SCRIPT438:对象不支持属性或方法 IE [英] SCRIPT438: Object doesn't support property or method IE

查看:61
本文介绍了SCRIPT438:对象不支持属性或方法 IE的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序中有一个选项,用户可以在其中停用他们的个人资料.只有管​​理员可以再次激活它们.

I have an option in my application where users can deactivate their profiles. Only admin can activate them again.

我有一个带有两种方法的 ActivateProfile

I have a class ActivateProfile with two methods

  • userExist(userName) 用于检查具有该用户名的用户是否存在并且他/她的个人资料是否已停用
  • activateAccountByUser(userName) 再次激活用户的个人资料
  • userExist(userName) that checks if user with that userName exists and his/her profile is deactivated
  • and activateAccountByUser(userName) that activate the profile of the user again

我在输入类型按钮的点击事件上调用一个 JavaScript 函数.此代码在 Chrome 和 Mozilla 上运行良好,但在 Internet Explorer 上出现此错误:

I call a JavaScript function on the click event of an input type button. This code works fine on Chrome and Mozilla, but on Internet Explorer I get this error:

SCRIPT438:对象不支持属性或方法 userExist

SCRIPT438: Object doesn't support property or method userExist

function activateProf() {        
   var userName=document.getElementById("userName").value;

   if (userName == "") {
      alert("Полето е задолжително");
   } else {
      alert(userName + "1");
      ActivateProfile.userExist(userName, { callback:function(exist) {
         if (userName) {
            ActivateProfile.activateAccountByUser(userName);
            alert("User is activated");
         } else {
            alert("User does not exist");
         }
      }});
   }
}

这是Activate profile类的代码

Here is the code for Activate profile class

 public void activateAccountByUser(String userName) {
    try {
        Connection c = DBComm.getInstance().getConnection();
        Statement s = c.createStatement();
        ResultSet set = s.executeQuery("select * from accounts where userName = '" + userName + "' and isauthorized='2'");

        if (set.next()) {
            Statement st = c.createStatement();
            st.executeUpdate("update accounts set isauthorized='1' where userName='" + userName                    + "' and isauthorized='2'");
        }
        s.close();
        c.close();
    } catch (Exception ex) {
        java.util.logging.Logger.getLogger(ActivateProfile.class.getName()).log(Level.SEVERE, null, ex);
    }
}

public boolean userExist(String userName) throws SQLException {
    //true exist
    //false does not exist
    boolean existEmbg = false;

    try {
        Connection c = DBComm.getInstance().getConnection();
        Statement s = c.createStatement();
        ResultSet set = s.executeQuery("select * from accounts where userName = '" + userName + "' and isauthorized='2'");

        if (set.next()) {
            existEmbg = true;
        } else {
            existEmbg = false;
        }
        s.close();
        c.close();
    } catch (Exception ex) {
       java.util.logging.Logger.getLogger(ActivateProfile.class.getName()).log(Level.SEVERE, null, ex);
    }
    return existEmbg;
}

推荐答案

在网上搜索了几天后,我发现这个错误通常发生在 html 元素 id 与 javascript 函数中的某个变量的 id 相同时.更改其中之一的名称后,我的代码运行良好.

After some days searching the Internet I found that this error usually occurs when an html element id has the same id as some variable in the javascript function. After changing the name of one of them my code was working fine.

这篇关于SCRIPT438:对象不支持属性或方法 IE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆