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

폰트 크기 제어

페이지 정보

작성자 MintState 댓글 0건 조회 10,751회 작성일 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 9825 11-17
77 MintState 14591 11-17
76 MintState 12485 11-17
75 MintState 14063 11-17
74 MintState 20389 11-17
73 MintState 14502 11-17
72 MintState 13047 11-17
71 MintState 14045 11-17
70 MintState 11990 11-17
열람중 MintState 10752 11-17
68 MintState 9580 11-17
67 MintState 10349 11-17
66 MintState 10063 11-17
65 MintState 11261 11-17
64 MintState 10132 11-17
63 MintState 14982 11-11
62 MintState 11623 11-10
61 MintState 10208 11-10
60 MintState 11032 11-10
59 MintState 12221 11-10
게시물 검색
모바일 버전으로 보기
CopyRight ©2004 - 2024, YesYo.com MintState. ™