폰트 크기 제어
페이지 정보
작성자 MintState 댓글 0건 조회 10,751회 작성일 08-11-17 11:24본문
폰트 크기 제어
font.js
<A href="javascript:PlusFont();">[크게]</A> <A href="javascript:MinusFont();">[작게]</A> <A href="javascript:SetArticleFont();">[저장]</A> <A href="javascript:SetDefaultFont();">[기본]</A> <DIV id=article style="WORD-BREAK: break-all; LINE-HEIGHT: 180%; TEXT-ALIGN: left"> 글내용 </DIV> <SCRIPT language=javascript src="font.js"></SCRIPT>
font.js
function SetDefaultFont() { var todayDate = new Date(); var name = "ArticleFont"; var expiredays = -1; var value = article.style.fontSize + "//" + article.style.fontFamily; todayDate.setDate( todayDate.getDate() + expiredays ); document.cookie = name + "=" + value + "; path=/; expires=" + todayDate.toGMTString() + ";" document.location.reload(); } function SetArticleFont() { var todayDate = new Date(); var name = "ArticleFont"; var expiredays = 365; var value = article.style.fontSize + "//" + article.style.fontFamily; todayDate.setDate( todayDate.getDate() + expiredays ); document.cookie = name + "=" + value + "; path=/; expires=" + todayDate.toGMTString() + ";" alert("현재의 글꼴과 글자크기 상태로 저장했습니다"); } function GetArticleFont(name){ var nameOfCookie = name + "="; var x = 0; while ( x <= document.cookie.length ) { var y = (x+nameOfCookie.length); if ( document.cookie.substring( x, y ) == nameOfCookie ) { if ( (endOfCookie=document.cookie.indexOf( ";", y )) == -1 ) endOfCookie = document.cookie.length; return document.cookie.substring( y, endOfCookie ); } x = document.cookie.indexOf( " ", x ) + 1; if ( x == 0 ) break; } return ""; } var Font; var fontsize; var fontface; var LineHeight = 16; temp = GetArticleFont("ArticleFont").split("//"); if (temp != "") { if(temp[0] == "") { fontsize = 9; fontface = "Verdana"; } else { fontsize = parseInt(temp[0]); fontface = temp[1]; if (fontsize > 9) { LineHeight = 12 + (fontsize-9);; } else { LineHeight = 12; } } } else { fontsize = 9; fontface = "Verdana"; } article.style.fontSize = fontsize +"pt"; article.style.fontFamily = fontface; article.style.lineHeight = LineHeight + "pt"; function PlusFont() { if (fontsize <= 15) { article.style.fontSize = (fontsize + 1) +"pt"; article.style.lineHeight = LineHeight + 1 + "pt"; fontsize = fontsize + 1; LineHeight = LineHeight + 1; } } function MinusFont() { if (fontsize >= 9) { article.style.fontSize = (fontsize - 1) +"pt"; article.style.lineHeight = LineHeight - 1 + "pt"; fontsize = fontsize - 1; LineHeight = LineHeight - 1; } } function FontCase(Font) { article.style.fontFamily = Font; } function SetFont() { var todayDate = new Date(); todayDate.setDate( todayDate.getDate() + 365 ); document.cookie = "Font = " + article.style.fontSize + "; path=/; expires=" + todayDate.toGMTString() + ";" }
|
댓글목록
등록된 댓글이 없습니다.