setExpression Method > html

본문 바로가기

html

setExpression Method

작성일 06-09-14 11:01

페이지 정보

작성자서방님 조회 109회 댓글 0건

본문

[Syntax] object.setExpression(sPropertyName, sExpression [, sLanguage])

The following syntax sections show how to set an expression on DHTML Properties and CSS attributes.

  • Use this syntax to set an expression on a read/write property or on an expando property.
    
    
  • Use this syntax to set an expression on a CSS attribute.
    
    
  • Use the expression() syntax to set an expression on a CSS attribute in HTML.

For example, Dynamic HTML (DHTML) can be used to position objects based on the location and measurement of other objects. The following equations are examples for centering an object horizontally or vertically.

  • Center the object horizontally:
    
    
  • Center the object vertically:
The following example shows how to set the expressions inline.
---------------------------------------------------------------------------
원하는 내용이 해당줄에서 항상 브라우저의 가운데에만 위치하도록 하는 예제
<SCRIPT>
window.onload=fnInit;

function fnInit(){
   oDiv.style.setExpression("left",
      "document.body.clientWidth/2 - oDiv.offsetWidth/2"
   );

   oDiv.style.setExpression("top",
      "document.body.clientHeight/2 - oDiv.offsetHeight/2"
   );
   document.recalc(true);
}
</SCRIPT>






<DIV ID="oDiv" STYLE="background-color: #CFCFCF; position: absolute; top: 0; left: 0;"> Example DIV </DIV>

댓글목록

등록된 댓글이 없습니다.

게시물 검색
Copyright © 서방님.kr All rights reserved.
PC 버전으로 보기