주 문서에 있는 behavior가 첨부된 태그의 참조를 반환한다.
![]() |
Script | [propVal=]elementObj.propName; |
HTML | 없슴 |
비헤이버가 첨주된 엘레멘트의 모든 속성들, 메서드들, 이벤트들은 이 HTC(HTML Component) 개체를 사용하여 에 접속할 수 있다. element 개체는 HTC 속에서 속성들, 메서드들, 이벤트들의 이름이 지정된 디폴트 개체이다. 따라서 이들은 element 키워드(keyword) 사용없이 직접적으로 지정할 수 있다.
![]() | element⇒ | ![]() | ⇒ | ![]() ![]() ![]() |
메서드 | 설명 |
---|---|
addBehavior | 엘레멘트에 behavior를 추가한다. |
createEventObject | PUBLIC:EVENT 엘레멘트의 이벤트 발생 메서드에 이벤트 컨텍스트 정보를 전달하는데 사용되는 event 개체를 생성한다. |
![]() | element⇒ | ![]() | ⇒ | ![]() ![]() ![]() |
엘레멘트의 이벤트에 첨부된 HTC로 엘레멘트의 글자색 color 스타일 속성을 'red'로 설정하고, cursor 스타일 속성을 'hand'로 설정한다.
<STYLE>.publicShow {behavior:url(../object/exp/myShow.htc)}</STYLE>
<DIV class="publicShow" id="showId" name="showName"
style="height:2em;border:solid 1 blue;color:blue;background:ffa" onclick="this.doShow()">클릭하여 결과 얻기</DIV>
../object/exp/myShow.htc 파일 내용
<PUBLIC:COMPONENT name="doShowCom">
<PUBLIC:METHOD name="doShow" />
<SCRIPT>
function doShow(){
str='event.type='+event.type+'\n';
str+='this.id='+this.id+'\n';
str+='this.name='+this.name+'\n';
str+='this.nodeName='+this.nodeName+'\n';
str+='this.className='+this.className+'\n';
str+='this.style.cssText='+this.style.cssText+'\n';
prevColor = this.style.color;
str+='this.style.color='+this.style.color+'\n';
element.style.color = 'red';
element.style.cursor = 'hand';
str+='element.style.color='+element.style.color+'\n';
str+='element.style.cursor='+element.style.cursor+'\n';
alert(str);
}
</SCRIPT>
</PUBLIC:COMPONENT>
![]() | element | ⇒ | ![]() ![]() |
최종 수정: 06/27/2025 14:02:00 | ![]() All right reserved | 비정상적인 방식으로 프레임없이 페이지에 접속하면 자주 오류가 발생됩니다. 오류가 나면 정상적 접속으로 시도해 보세요. | http://koxo.com/lang/js/object/element_HTC.html |