IE6, 8 및 Firefox를 지원하는 데 필요한 크로스 브라우저 플랫폼을 통해 Javascript로 작업하려고합니다. 나는이 브라우저들 중 어느 브라우저도 일치하는 Javascript 라이브러리를 가지고 있지 않다는 것을 빨리 발견했다.IE6, 8 및 Firefox에서 스타일 속성 제거
목표는 다른 항목의 선택에 따라 동적으로 숨기거나 표시하는 항목을 갖는 것입니다. 일반적으로 display : none과 display : block 사이를 토글하는 것이지만, 다른 개발자의 작업을 위해 display : none을 사용하여 필드를 숨길 수 있지만 디스플레이로 전환하면 레이아웃을 차단합니다. 해결책은 단순히 스타일의 디스플레이 설정을 추출하거나 스타일을 완전히 찢어 버리는 것입니다. 불행히도, 난
파이어 폭스가 지원하는 라이브러리 문제로 실행 내가 ('디스플레이') IE6가에서 getElementById를 지원하지 않습니다에서 getElementById(). style.removeProperty을 지원하지 않았다 지금까지 IE8 & 6 해봤 다() .removeAttribute ('style')
아래 코드는 현재 IE8과 FF로 작업 중입니다 ...하지만 IE6에서도 작동해야합니다.
function displayPrevLPQ(bShow) {
if (bShow) {
document.getElementById('prevLPQ').removeAttribute('style');
} else {
document.getElementById('prevLPQ').style.display = 'none';
}
}
function displayBusUnitSub() {
var buVal = document.getElementById('BusinessUnitID').value;
document.getElementById("BusinessCycle").selectedIndex = document.getElementById("BusinessCycle").getAttribute("default");
document.getElementById("Ibap").selectedIndex = document.getElementById("Ibap").getAttribute("default");
document.getElementById("Bca").selectedIndex = document.getElementById("Bca").getAttribute("default");
switch (buVal) {
case '11':
document.getElementById('buSub0').style.display = 'none';
document.getElementById('buSub1').removeAttribute('style');
document.getElementById('buSub2').style.display = 'none';
break;
case '1':
document.getElementById('buSub0').style.display = 'none';
document.getElementById('buSub1').style.display = 'none';
document.getElementById('buSub2').removeAttribute('style');
break;
default:
document.getElementById('buSub0').removeAttribute('style');
document.getElementById('buSub1').style.display = 'none';
document.getElementById('buSub2').style.display = 'none';
break;
}
}
그럼, 어떻게 세 가지 브라우저에서 작동하는 방식으로 스타일이나 표시 속성을 찢을 수 있습니까?
미리 감사드립니다.
요즘에는 IE6를 사용해야하는 사람은 정말 동정입니다. :-( – Spudley