IE7의 일부 JS에 문제가 있습니다. 특정 객체에 className (DOM의 HTMLElement 객체)이 할당되었는지 확인하려고합니다.Internet Explorer 7 - Javascript 'undefined'가 테스트되지 않습니다.
이제 파이어 폭스에서 페이지를 테스트하는 것은 예, 변수가 정의되지 하더군요 (내 모든 시험은 아래의 경고을(). IE에서
는 시험 중 어느 것도 통과하지 변수는에 할당됩니다 문 IF, 마지막 경고 중 마지막() IE는이fn_note.className
문에 따라 오류 "클래스 이름이 null 여부를 객체이다"척 여기
코드입니다 :.
var fn_note;
var kids = area.childNodes;
for (var l = 0; l < kids.length; l++){
//DEBUG check if the found var exists
if (kids[l].className == null){
//then the className var doens't exist
alert ('the classsname for the following var is null: --'+kids[l]+'--');
}
if (kids[l].className == undefined){
//then the className var doens't exist
alert ('the classsname for the following var is undefined: --'+kids[l]+'--');
}
if (kids[l].className == ''){
//then the className var doens't exist
alert ('the classsname for the following var is an empty string: --'+kids[l]+'--');
}
if (typeof kids[l].className === 'undefined'){
//then the className var doens't exist
alert ('the classsname for the following var is NEW TYPEOF TEST: --'+kids[l]+'--');
}
if (kids[l].className == 'fn-note') { /* (/fn-note$/).test(kids[l].className) IE doesn't really like regex. por supuesto */
//we have found the div we want to hide
fn_note = kids[l];
}
}
alert('the clicked on className is '+area.className+'name of the found div is '+fn_note.className);
알려 주시기 바랍니다 내가 뭘 잘못하고 있는지. 아마 그 중 일부는 알고있다. 기본적이지만 현금으로 만 볼 수는 없습니다.
미리 감사드립니다.
IE7에서 막 테스트되었습니다. http://jsbin.com/azoya/ 빈 문자열을보고합니다. – strager
또한 여기에서 빈 문자열을 테스트했습니다. – eglasius