YesYo.com MintState Forums
뒤로    YesYo.com MintState BBS > Tech > Javascript
검색
멤버이름    오토
비밀번호 
 

폰트 크기 제어

페이지 정보

작성자 MintState 댓글 0건 조회 8,266회 작성일 08-11-17 11:24

본문

폰트 크기 제어

<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() + ";"			
		}

댓글목록

등록된 댓글이 없습니다.

Total 178건 6 페이지
Javascript 목록
번호 제목 글쓴이 조회 날짜
78 MintState 7545 11-17
77 MintState 11841 11-17
76 MintState 9616 11-17
75 MintState 11221 11-17
74 MintState 17966 11-17
73 MintState 10813 11-17
72 MintState 10317 11-17
71 MintState 11344 11-17
70 MintState 9475 11-17
열람중 MintState 8267 11-17
68 MintState 7349 11-17
67 MintState 8094 11-17
66 MintState 7635 11-17
65 MintState 8724 11-17
64 MintState 7527 11-17
63 MintState 12417 11-11
62 MintState 9189 11-10
61 MintState 7761 11-10
60 MintState 8437 11-10
59 MintState 9517 11-10
게시물 검색
모바일 버전으로 보기
CopyRight ©2004 - 2021, YesYo.com MintState. ™