SCRIPT438: Object does not support IE property or method

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

I have an ActivateProfile class with two methods

  • userExist(userName) , which checks if a user with this username exists and his / her profile is disabled.
  • and activateAccountByUser(userName) , which again activate the user profile.

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

SCRIPT438: object does not support userExist property or method

 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"); } }}); } } 

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; } 
+42
javascript internet-explorer
Dec 20 '12 at 15:57
source share
8 answers

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

+71
Dec 22
source share

This is a common problem in web applications that use the JavaScript namespace. In this case, the problem 99.9% of the time is IE's inability to bind methods in the current namespace to the keyword "this".

For example, if I have a JS "StackOverflow" namespace with the "isAwesome" method. Normally, if you are in the "StackOverflow" namespace, you can call the "isAwesome" method with the following syntax:

 this.isAwesome(); 

Chrome, Firefox, and Opera are happy to accept this syntax. IE, on the other hand, will not. Thus, the safest bet when using JS namespacing is always the prefix with the actual namespace. A la:

 StackOverflow.isAwesome(); 
+7
Aug 28 '14 at 14:11
source share

I added var for all variables in aggressive javascript. This solved the problem in IE.

Previous code

 billableStatus = 1 ; var classStr = $(this).attr("id").split("_"); date = currentWeekDates[classStr[2]]; // Required activityNameId = "initialRows_" + classStr[1] + "_projectActivityName"; activityId = $("#"+activityNameId).val(); var projectNameId = "initialRows_" + classStr[1] + "_projectName" ; projectName = $("#"+projectNameId).val(); var timeshitEntryId = "initialRows_"+classStr[1]+"_"+classStr[2]; timeshitEntry = $("#"+timeshitEntryId).val(); 

New code

 var billableStatus = 1 ; var classStr = $(this).attr("id").split("_"); var date = currentWeekDates[classStr[2]]; // Required var activityNameId = "initialRows_" + classStr[1] + "_projectActivityName"; var activityId = $("#"+activityNameId).val(); var projectNameId = "initialRows_" + classStr[1] + "_projectName" ; var projectName = $("#"+projectNameId).val(); var timeshitEntryId = "initialRows_"+classStr[1]+"_"+classStr[2]; var timeshitEntry = $("#"+timeshitEntryId).val(); 
+5
Mar 04 '13 at 12:33
source share

My problem was type="application/javascript" in the <script> for jQuery. IE8 doesn't like it! If your webpage is HTML5, you don’t even need to declare a type, otherwise use type="text/javascript" .

+1
Nov 15 '13 at 21:37
source share

In my case, I had code like this:

 function.call(context, arg); 

I got an error in IE

TypeError: Object does not support the property or method 'error'

In the "function" body, I had "console.error", and this console object becomes undefined when the console is closed. I fixed this by checking if console and console.error are defined.

+1
Jan 27 '16 at 12:59 on
source share

I forgot to use var in my item variable

Incorrect code:

 var itemCreateInfo = new SP.ListItemCreationInformation(); item = list.addItem(itemCreateInfo); item.set_item('Title', 'Haytham - Oil Eng'); 

The correct code is:

 var itemCreateInfo = new SP.ListItemCreationInformation(); var item = list.addItem(itemCreateInfo); item.set_item('Title', 'Haytham - Oil Eng'); 
0
May 15 '15 at 11:24
source share

This problem may occur due to the wrong version of jquery. e.g. 1.4 etc. when the method is not supported

-one
Nov 18 '13 at 11:11
source share

I had the following

 document.getElementById("search-button") != null 

which worked great in all browsers except ie8. (I did not check ie6 or ie7)

I changed it to

 document.getElementById("searchBtn") != null 

and updated the id attribute in the field in my html and now it works in ie8

-one
Dec 20 '13 at 19:01
source share



All Articles