SCRIPT438 : 개체가 속성 또는 메서드 IE를 지원하지 않습니다.
내 애플리케이션에 사용자가 프로필을 비활성화 할 수있는 옵션이 있습니다. 관리자 만 다시 활성화 할 수 있습니다.
ActivateProfile
두 가지 방법 으로 수업 이 있습니다
userExist(userName)
해당 userName을 가진 사용자가 존재하고 그 / 그녀의 프로필이 비활성화되었는지 확인하는- 그리고
activateAccountByUser(userName)
다시 상기 사용자의 프로파일을 활성화하는
입력 유형 버튼의 클릭 이벤트에 대해 JavaScript 함수를 호출합니다. 이 코드는 Chrome 및 Mozilla에서는 잘 작동하지만 Internet Explorer에서는 다음 오류가 발생합니다.
SCRIPT438 : 개체가 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 프로필 클래스의 코드입니다.
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;
}
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.
This is a common problem in web applications which employ JavaScript namespacing. When this is the case, the problem 99.9% of the time is IE's inability to bind methods within the current namespace to the "this" keyword.
For example, if I have the JS namespace "StackOverflow" with the method "isAwesome". Normally, if you are within the "StackOverflow" namespace you can invoke the "isAwesome" method with the following syntax:
this.isAwesome();
Chrome, Firefox and Opera will happily accept this syntax. IE on the other hand, will not. Thus, the safest bet when using JS namespacing is to always prefix with the actual namespace. A la:
StackOverflow.isAwesome();
I have added var for all the variables in the corrosponding javascript. That 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();
My problem was having type="application/javascript"
on the <script>
tag for jQuery. IE8 does not like this! If your webpage is HTML5 you don't even need to declare the type, otherwise go with type="text/javascript"
instead.
In my case I had code like this:
function.call(context, arg);
I got error message under IE
TypeError: Object doesn't support property or method 'error'
In the body of 'function' I had "console.error" and it turns that console object is undefined when your console is closed. I have fixed this by checking if console and console.error are defined
I forgot to use var
on my item variable
Incorrect code:
var itemCreateInfo = new SP.ListItemCreationInformation();
item = list.addItem(itemCreateInfo);
item.set_item('Title', 'Haytham - Oil Eng');
Correct code:
var itemCreateInfo = new SP.ListItemCreationInformation();
var item = list.addItem(itemCreateInfo);
item.set_item('Title', 'Haytham - Oil Eng');
Implement "use strict"
in all script tags to find inconsistencies and fix potential unscoped variables!
We were able to solve this problem by adding in the Object.Assign polyfill to the files being imported and throwing the error. We would make it the highest import, that way it would be available to the other code to be called in the stack.
import "mdn-polyfills/Object.assign";
This issue may be occurred due to improper jquery version. like 1.4 etc. where done method is not supported
I had the following
document.getElementById("search-button") != null
which worked fine in all browsers except ie8. ( I didnt check ie6 or ie7)
I changed it to
document.getElementById("searchBtn") != null
and updated the id attribute on the field in my html and it now works in ie8
참고URL : https://stackoverflow.com/questions/13975922/script438-object-doesnt-support-property-or-method-ie
'programing tip' 카테고리의 다른 글
컴퓨터가 절전 모드가되면 setTimeout은 어떻게됩니까? (0) | 2020.12.13 |
---|---|
파일에 안전하게 쓰는 Python 다중 처리 (0) | 2020.12.12 |
Cygwin 32 비트에서 Cygwin 64 비트로 전환하는 것이 좋습니까? (0) | 2020.12.12 |
CSS 전달 최적화 : CSS 로딩을 연기하는 방법? (0) | 2020.12.12 |
persistence.xml에서 JPA 2.1을 지정하는 방법은 무엇입니까? (0) | 2020.12.12 |