Q&A

안녕하세요.

게시판의 본문 영역을 사용해보고 싶은데요.

잘 안되는 것 같습니다. 도움 부탁드려요.

 

제가 생각한 방법은

1. 게시판 본문은 'xe_content'라는 class로 지정된다.

2. getElementByClassName 으로 xe_content를 찾아낸다.

3. 높이를 구한다

 

인데 전체 코드는 아래와 같구요.

그런데 잘 작동이 안되는 것 같아요 ㅠㅠ

 

 

 

 

     var xeHeight=10; //test를 위한 기본 값


        xe_content = document.getElementsByClassName("xe_content");
        if(!xe_content) xeHeight = 30; //className으로 찾지 못하면 30출력
        if (xe_content.getBoundingClientRect().height) {
            xeHeight = 40; //여기까지왔다면 40
            xeHeight = xe_content.getBoundingClientRect().height; // for modern browsers 
        } 
        else {
            xeHeight = 50; //여기까지왔다면 50
            xeHeight = xe_content.offsetHeight; // for old IE 
        }

 

 

인데 xeHeight를 출력해보면 10으로만 나옵니다.

댓글 2