2011-09-28 5 views
2

프레임 워크로 작업하지 않아도, 기본적으로 JavaScript로 작업하고 있습니다.IE에서 입력 요소의 너비는 어떻게됩니까?

width = document.defaultView.getComputedStyle(el, "").getPropertyValue('width'); 

그러나 F에서 ** Internet Explorer를 사용 보내고 :

if (typeof el.currentStyle['width'] == "undefined" || el.currentStyle['width'] == 'NaN') { 
    width = el.currentStyle['width']; 
} else { 
    width = null; 
} 

이 작품을

나는 좋은 브라우저에서 내가 사용, 입력 텍스트 요소의 폭을 알 필요가 , CSS 또는 스타일 속성에 의해 너비가 설정되어 있지만 크기가 기본값 (크기 속성 또는 설정되지 않음으로 설정) 인 경우 el.currentStyle [ 'width']은 정의되지 않습니다.

속성 집합이없는 요소의 너비를 알아야합니다.

+6

는 IE – frosty

+0

에 대해 욕설 위해 투표를 참조 http://stackoverflow.com/questions/171542/proper-ie6-html-element-dimensions 당신은 –

+0

.width()'- 어떻게 든 모르겠다. –

답변

1
var elwidth= el.offsetWidth+'px'; 
-1

그냥 Jquery를 사용하십시오. 그것은 ie6에서도 작동하는 .width 및 .height 함수를 가지고 있습니다.

관련 문제