Table for Layout vs CSS Layout

2008/06/09 00:41
웹에 종사하는 많은 사람들이 이미 웹표준에 대해 경험하고 실무에 적용하고 있다.
본인의 경우 웹표준에 대해 접하기 시작한 것은 작년 말부터 이며, 실제 실무에 적용하기 시작한 것은 그리 얼마 되지 않는다.
테이블 코딩에서 완전한 CSS로의 전환은 많은 시행착오를 필요로 했다. CSS가 여타 프로그램 언어처엄 에러를 명시적으로 표시해주지 않으니 디버깅 시간을 많이 필요로 했다. 하지만 아래의 글과 같이 많은 이점을 가져다 준다.
특히 고객에게 금전적 이익을 가져다 줄 수 있다는 것이다. 이부분에 대하여 많은 이야기가 있을 수 있고 사이트 성격에 따라 달라질 수 있겠으나(개발 공수가 늘어 프로젝트 비용이 증가할 수도 있겠다.) 본인이 관리하는 사이트의 경우 웹표준으로 전환하고 전체 페이지 사이즈가 78%나 준것을 경험할 수 있었다. 이것은 실제 네트웍에 흐르는 데이터가 이 만큼 감소한다는 이야기로 방문자가 많은 사이트 일수록  비용적 측면에서 확실히 이득이 된다.
꿈일 지도 모르나 전세게 웹사이트가 웹표준으로 이전을 한다면 전체 네트웍의 소통이 점더 원할하고, 투자비용도 아낄 수 있지 않을까 생각해 본다.

아래의 내용은 정찬명님의 포스팅한 글을 싣는다.


정찬명님의 글
http://naradesign.net/wp/2007/02/03/113/


약 1년 전 네이버 블로그를 사용하면서 동일한 실험을 했던 적이 있습니다. 그 당시에는 Table Layout과 DIV Layout을 비교한다고 말했었지만 사실 Table Layout 이라는 말과 DIV Layout 이라는 말은 모두 잘못된 표현입니다. Table Layout 이라는 용어는 Table이 격자형의 2차원 데이터를 마크업 하는 용도를 지니고 있다는 점에서 Layout 이라는 표현과 함께 사용한 것이 잘못된 표현이며, DIV Layout 이라는 용어는 DIV가 의미를 그룹짓는 용도를 지니고 있다는 점에서 역시 Layout과 결합한 것은 잘못된 표현 입니다. 결국 Layout 이라는 것은 화면배치를 위한 표현에 해당하기 때문에 어떤 (X)HTML 요소와도 조합하여 사용하는 것은 잘못된 표현이라고 할 수 있습니다. Table Layout 이라는 말은 사실 ‘Table for Layout’ 즉, ‘레이아웃을 위하여 사용된 테이블’ 정도로 밖에 표현할 수 없습니다. 두 가지 표현이 별반 차이가 없는 것처럼 느껴지는 분들도 계실테지만 사실 엄청난 차이가 존재합니다. 전자는 Table이 Layout을 위하여 사용되고 있고 또 그럴 수도 있다는 것을 전제 하지만 후자는 Table이 Layout 용도로 사용되는 것을 확실하게 경계하였기 때문에 사용되는 표현입니다. 어쨌거나 이미 네이버에서만 162분이나 스크랩을 하셨고 저는 1년이 지난 최근에서야 해당 포스트를 수정하였는데 1년동안 여러 분들께 잘못된 정보를 제공했다는 사실 때문에 약간의 죄책감을 가지게 되었습니다. 그것을 만회할 요량으로 다시 해당 코드를 손질하고 이곳에 올려놓습니다. 이제는 자수하여 광명찾고 싶습니다.

Table for Layout 예제보기 CSS Layout 예제보기
Table for Layout CSS Layout

웹 표준 방식의 CSS Layout은 콘텐트가 논리적으로 선형화 됩니다.

상기 두 개의 이미지는 동일한 Layout을 제공하고 있지만 코드는 각각 다릅니다. 이미 짐작하고 계셨겠지만 이번에는 CSS를 제거한 상태로 한번 보여드리겠습니다. CSS를 제거하게 되면 콘텐트가 선형화 되는 모습을 시각적으로 확인할 수 있고 선형화 하였을 때 콘텐트의 나열 순서에 무리가 없다면 그것은 어떤 장치에서 보더라도 논리적으로 바르게 이해할 수 있습니다. 왼쪽은 화면배치를 위하여 Table이 사용된 페이지이며 오른쪽이 CSS를 이용하여 Layout된 페이지 입니다. Opera Mini와 같은 휴대용 웹 브라우징 장치는 웹 페이지를 렌더링 할 때 Table을 모두 걷어내고 CSS조차 제거된 상태로 표시합니다. 따라서 아래 두 가지 경우의 페이지 가운데 어떤 페이지가 논리적으로 선형화 될 것인지는 굳이 보지 않더라도 쉽게 추측이 가능합니다. 사실 이것은 CSS Layout의 영향이라기 보다는 Markup을 잘 했기 때문에 볼 수 있는 결과 입니다. 하지만 거꾸로 생각하면 표현요소가 Markup으로부터 완전히 분리되어 있기 때문에 이렇게 논리적으로 Markup 하는것이 가능해 집니다. Layout에 Table을 사용하는 경우는 마크업이 표현요소를 포함하고 있기 때문에 콘텐트를 논리적으로 배치하려고 시도하면 표현문제와 충돌하게 되고 결국 논리보다는 표현을 위한 용도로 마크업을 사용하게 되어 논리적인 배치와는 거리가 멀어지게 됩니다.

CSS가 제거된 Table for Layout 예제보기 CSS가 제거된 Web Standard Layout 예제보기
Table for Layout Without CSS CSS Layout Without CSS

보통 Table을 선형화 하더라도 콘텐트의 순서가 완전히 뒤죽박죽으로 인식되지는 않습니다. 왜냐하면 Table을 걷어내는 경우 좌측 상단으로부터 우측 하단으로 콘텐트가 선형화 되는데 그러한 순서에 맞게 페이지의 콘텐트를 배치하는 경우도 있기 때문입니다. 그러나 그것은 운이 아주 좋은 경우이며 대부분의 경우는 논리적인 순서에 문제가 생기게 됩니다.

CSS Layout은 Table for Layout에 비하여 파일의 용량을 50% 이상 절감해 줍니다.

무엇인가 원하는 위치에 표시하기 위하여 Table을 Layout에 사용하는 경우는 <table><tr><td>내용</td></tr></table> 형식으로 코딩 되지만 CSS Layout은 <div>내용</div> 형식으로 코딩 됩니다. 예제코드 전체를 보여드리겠습니다. 화면(또는 지면) 관계상 코드를 모두 담아내면 화면이 너무 커지므로 코드의 서체크기를 일부러 줄여 놓았습니다. 코드를 자세히 확인하시려면 그냥 복사해서 메모장에서 볼 것을 권합니다.

Table for Layout CSS Layout
89 line 39 line
2,661 byte 1,027 byte
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=euc-kr” />
<title>Table for Layout</title>
<link href=”TableForLayout.css” rel=”stylesheet” type=”text/css” />
</head>
<body style=”margin:0″>
<p id=”moveTo”><a href=”CSSLayout.html”>Go to CSS Layout</a></p>
<table width=”100%” border=”0″ cellspacing=”0″ cellpadding=”20″>
<tr>
<td colspan=”3″ valign=”top” id=”header”>Table for Layout</td>
</tr>
<tr>
<td width=”20%” height=”300″ valign=”top” style=”background:#666″><table width=”100%” border=”0″ cellspacing=”0″ cellpadding=”5″ id=”menu”>
<tr>
<th style=”height:30px; background:#999″>2Depth Title </th>
</tr>
<tr>
<td>Menu1</td>
</tr>
<tr>
<td class=”line”></td>
</tr>
<tr>
<td>Menu2</td>
</tr>
<tr>
<td class=”line”></td>
</tr>
<tr>
<td>Menu3</td>
</tr>
<tr>
<td class=”line”></td>
</tr>
<tr>
<td>Menu4</td>
</tr>
<tr>
<td class=”line”></td>
</tr>
<tr>
<td>Menu5</td>
</tr>
<tr>
<td class=”line”></td>
</tr>
</table></td>
<td width=”60%” height=”300″ valign=”top” style=”background:#999″><table width=”100%” border=”0″ cellspacing=”0″ cellpadding=”5″ id=”pageTitle”>
<tr>
<th style=”height:30px”>3Depth Title </th>
</tr>
</table>
<table width=”100%” cellspacing=”0″>
<tr>
<td id=”text”>Content </td>
</tr>
</table></td>
<td width=”20%” height=”300″ valign=”top” style=”background:#CCC”><table width=”100%” border=”0″ cellspacing=”0″ cellpadding=”5″ id=”links”>
<tr>
<th style=”height:30px; background:#666″>Links </th>
</tr>
<tr>
<td>Link List 1</td>
</tr>
<tr>
<td class=”line”></td>
</tr>
<tr>
<td>Link List 2 </td>
</tr>
<tr>
<td class=”line”></td>
</tr>
<tr>
<td>Link List 1</td>
</tr>
<tr>
<td class=”line”></td>
</tr>
</table></td>
</tr>
<tr>
<td colspan=”3″ valign=”top” id=”footer” style=”background:#333″><a href=”http://naradesign.net/”>naradesign.net</a></td>
</tr>
</table>
</body>
</html>
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=euc-kr” />
<title>CSS Layout</title>
<link href=”CSSLayout.css” rel=”stylesheet” type=”text/css” />
</head>
<body>
<p id=”moveTo”><a href=”TableForLayout.html”>Go to Table for Layout</a></p>
<h1>CSS Layout</h1>
<div id=”center”>
<div id=”menu”>
<h2>2Depth Title </h2>
<ul>
<li>Menu1</li>
<li>Menu2</li>
<li>Menu3</li>
<li>Menu4</li>
<li>Menu5</li>
</ul>
</div>
<div id=”content”>
<h3>3Depth Title </h3>
<div id=”text”> Content </div>
</div>
<div id=”links”>
<h3>Links</h3>
<ul>
<li>Link List 1</li>
<li>Link List 2</li>
<li>Link List 3 </li>
</ul>
</div>
</div>
<address id=”footer”>
<a href=”http://naradesign.net/”>naradesign.net</a>
</address>
</body>
</html>
Table for Layout CSS Layout
17 line 23 line
1,030 byte 1,771 byte
* { font-size:small; font-family:Arial}
a { font:inherit; color:#FFF; text-decoration:none}
a:hover { text-decoration:underline}
#moveTo { position:absolute; top:4em; right:2em}
#header { font-size:5em; color:#FFF; font-weight:bold; background:#000}
#menu th { border-bottom:3px solid #FFF; font-size:x-large; font-weight:bold; color: #FF0; text-align:left}
#menu td { font-size:small; font-weight:bold; color:#FFF}
#menu td.line { height:1px; padding:0; background:#FFF}
#pageTitle { margin-bottom:1em; background:#999}
#pageTitle th,
#link th {border-bottom:3px solid #FFF; font-size:x-large; font-weight:bold; color: #FF0; text-align:left; background:#666}
#text { color:#FFF;}
#links { margin-bottom:1em}
#links th {border-bottom:3px solid #FFF; font-size:x-large; font-weight:bold; color: #FF0; text-align:left; background:#666}
#links td { color:#FFF}
#links td.line { height:1px; padding:0; background:#FFF}
#footer { font-family: Verdana; font-size:x-large; font-weight:bold; font-style:italic; color:#FFF}
* { margin:0; padding:0; font-size:small; font-family:Arial}
h1 { font-size:5em; color:#FFF; font-weight:bold; background:#000; padding:20px}
h2 { padding:5px; font-size:x-large; font-weight:bold; color:#FF0; background:#999; border-bottom:3px solid #FFF; margin:20px; margin-bottom:0}
h3 { padding:5px; font-size:x-large; font-weight:bold; color:#FF0; background:#666; border-bottom:3px solid #FFF; margin:20px; margin-bottom:0}
a { font:inherit; color:#FFF; text-decoration:none}
a:hover { text-decoration:underline}
#moveTo { position:absolute; top:4em; right:2em}
#center { position:relative; overflow:hidden}
#menu { position:relative; width:20%; background:#666; float:left; height:300px}
#menu ul { margin:20px; margin-top:0; padding:0}
#menu li { padding:5px; border-bottom:1px solid #FFF; font-weight:bold; color:#FFF; list-style:none}
#content { position:relative; background: #999; font-size:small; font-family:Verdana; color:#FFF; width:60%; float:left; height:300px}
#content h3 { margin-bottom:1em}
#text { margin:20px; margin-top:0; line-height:150%; font-family:Verdana}
#text table { border-left:1px solid #CCC; border-top:1px solid #CCC}
#text table caption { font-weight:bold; text-align:left}
#text table th { background:#666}
#text table th,
#text table td { padding:.5em; border-right:1px solid #CCC; border-bottom:1px solid #CCC; text-align:center}
#links { position:relative; float:left; background:#CCCCCC; width:20%; clear:right; height:300px}
#links ul { margin:20px; margin-top:0; padding:0}
#links li { padding:5px; border-bottom:1px solid #FFF; color:#FFF; list-style:none}
#footer { position:relative; clear:both; background: #333; font-family: Verdana; font-size:x-large; font-weight:bold; color:#FFF; padding:20px }

CSS Layout의 경우 HTML 파일의 용량은 50% 이상 절감됩니다. CSS파일의 용량은 약 70% 정도 증가하였지만 CSS파일은 웹 사이트 접속시 딱 한번 로드되고 로컬 PC의 캐시메모리에서 재활용 되므로 전송량에 미치는 부하는 무시해도 좋은 수준입니다. 이 실험에서는 비록 하나의 웹 페이지를 단순 비교하였지만 웹 페이지의 수가 증가하면 증가할 수록 웹 표준 방식의 CSS Layout Code는 경제적인 효과가 배가됩니다.

사람이나 로봇(컴퓨터)이 이해하기 쉬운 구조가 됩니다.

코드가 줄어들기 때문에 개발자들이 코드보기가 수월해 진다는 것은 쉽게 추측할 수 있습니다. 즉, 삽질을 줄여주죠. 하지만 그런 점은 겨우 부가적인 이점에 불과합니다. 웹 표준 방식의 HTML 코드는 모바일 장치를 포함한 어떤 종류의 웹 브라우저 장치에서 출력 되더라도 그것을 이해할 수 있는 수준으로 렌더링 됩니다. 또한 검색엔진으로부터 높은 점수를 받습니다. 특히 Title 태그와 h1~h6 등의 제목태그 및 alt 텍스트를 사용할 때 그렇습니다. 검색엔진의 접근성이 높아져서 피검색 될 확률이 높아집니다.

유지보수가 쉬워지고 유지보수 비용을 절감시켜 줍니다.

웹 사이트의 디자인만 개편한다고 가정할 때 Table 기반으로 Layout된 페이지들은 Layout을 변경하기 위하여 수천 페이지의 HTML 문서를 모두 열어서 수정해야 하는 고통이 따릅니다. 하지만 CSS 기반으로 Layout된 웹사이트는 HTML 파일은 열어볼 필요조차 없어집니다. 불과 몇개의 CSS파일을 수정하는 것으로 매우 간단하게 수천개의 웹 페이지 디자인을 개편할 수 있습니다. 표현요소를 CSS로 완벽하게 분리했다면 HTML파일을 수정해야 하는 상황은 오직 데이터가 업데이트 될 때 뿐입니다.

웹 접근성 문제는 웹 표준만 지키면 90% 이상 해결 됩니다.

웹은 태어날 때부터 보편성을 전제하였습니다. 즉, 웹 표준만 지키면 누구나 접근할 수 있도록 이미 그렇게 설계 되어 있다는 의미 입니다. 가장 짧은 시간에 접근성을 크게 증진시킬 수 있는 방법으로서 image 요소에 대한 alt 텍스트를 강조하고 있는데 이것은 WCAG 지침이기 이전에 XHTML 표준 문법입니다. 실제로 WCAG 지침은 XHTML의 표준 문법 가운데 접근성 이슈만 추려내 놓고 그것을 지키라고 말하는 문장이 많습니다.

이올린에 북마크하기(0) 이올린에 추천하기(0)

happyness WEB ,

2008/06/09 00:41 2008/06/09 00:41
[로그인][오픈아이디란?]

새로운 직업군 웹 퍼블리셔

2008/06/03 00:29
웹표준이라는 화두 속에서 웹퍼블리셔라는 직업군이 새롭게 등장하고 있다.
어떻게 보면 예전의 코더에서 퍼블리셔라는 것으로 진화한다고볼 수도 있겠으나, 코더 보다는 좀더 상위 개념으로 보는게 좋을것 같다는 생각을 한다.

현업에서, HTML을 XHTML로 전환하고 웹표준에 맞게 코딩하고 하는 일련의 작업을 진행하면서 느끼는 것은 어떻게 웹표준에서 말하는 구현, 동작, 표현을 분리하여 얼마나 구조적인 문서를 만드느냐, 외부 검색엔진(Google, Yahoo, ...)에 대한 대응, 접근성 향상, 크로스 브라우징등등 많은 것을 고려한다는 것은 그렇게 쉽게 다가오는 문제는 아닌것 같다.

이렇다 보니 나 스스로가 좀더 전문적인 지식을 습득해야 하거나, 전문적인 지식을 습득한 사람이 필요로 하게된다. 이런 것들이 좀더 발전하여 전문지식을 습득하고, 계획 및 통제, 관리를 할 수 있는 사람들을 웹퍼블리셔라 부르고 있다.
이올린에 북마크하기(0) 이올린에 추천하기(0)

happyness WEB ,

2008/06/03 00:29 2008/06/03 00:29
[로그인][오픈아이디란?]

웹표준에서 HTML이 아닌 XHTML을 선택하나

2008/06/03 00:14
웹문서를 작성하는데 있어 HTML, XHTML, XML등을 이용하여 표현한다. 하지만 웹표준을 준수하고 표현하는 데에서는 XHTML을 이용한다. XHTML을 사용하는 이유는 사용가능한 요소와 속성이 HTML과 거의 같고, 배우기 쉬우며, 현재 나와 있는 브라우져들이 이를 충분히 지원하기 때문이다.

또한 아래와 같은 큰 특징들이 있다.

1. 빠른 데이터 처리와 안정적 브라우져 동작
2. 데이터 재 사용과 정보 공유 촉진
3. 네임스페이스 이용과 다양한 기기 대응


이올린에 북마크하기

happyness WEB/XHTML and CSS , ,

2008/06/03 00:14 2008/06/03 00:14
[로그인][오픈아이디란?]

WEB 2.0의 10대 기술 요소

2008/05/26 12:54
과연 WEB 2.0 이 무엇일까? 트랜드가 아닐까 생각한다.
모질라가 개발되고, 인터넷이 막 시작되던 시절에는 그 자체로만으로 과히 혁명적 이었다. 이 렇게 시간이 흐로고 기술들이 무르익어 제2의 개화기를 맞이 했다고 생각해도 될것 같다.

WEB 2.0을 이루는 요소들은 아래와 같다.

1. 웹 표준(XHTML/CSS)
2 브라우저 지원(Firefox, Safari)
3 유니코드 (UTF-8)
4 논리적 주소체계 (Logical URI)
5 컨텐츠 신디케이션(RSS/Atom, RDF)
6 오픈 API (REST, SOAP, Web Services)
7 집단 지성(Folksnomy, Tag)
8 가벼운 서비스 프레임웍(Python, Ruby on Rails)
9 풍부한 사용자 경험(Ajax, Flex)
10 확장 기능 (Firefox Extensions, Widget)
이올린에 북마크하기

happyness WEB

2008/05/26 12:54 2008/05/26 12:54
[로그인][오픈아이디란?]

SEO 의 10가지 실수

2008/05/24 01:09

1. Targetting the wrong keywords
This is a mistake many people make and what is worse – even experienced SEO experts make it. People choose keywords that in their mind are descriptive of their website but the average users just may not search them. For instance, if you have a relationship site, you might discover that “relationship guide” does not work for you, even though it has the “relationship” keyword, while “dating advice” works like a charm. Choosing the right keywords can make or break your SEO campaign. Even if you are very resourceful, you can't think on your own of all the great keywords but a good keyword suggestion tool, for instance, the Website Keyword Suggestion tool will help you find keywords that are good for your site.


2. Ignoring the Title tag
Leaving the <title> tag empty is also very common. This is one of the most important places to have a keyword, because not only does it help you in optimization but the text in your <title> tag shows in the search results as your page title.


3. A Flash website without a html alternative
Flash might be attractive but not to search engines and users. If you really insist that your site is Flash-based and you want search engines to love it, provide an html version. Here are some more tips for optimizing Flash sites. Search engines don't like Flash sites for a reason – a spider can't read Flash content and therefore can't index it.


4. JavaScript Menus
Using JavaScript for navigation is not bad as long as you understand that search engines do not read JavaScript and build your web pages accordingly. So if you have JavaScript menus you can't do without, you should consider build a sitemap (or putting the links in a noscript tag) so that all your links will be crawlable.


5. Lack of consistency and maintenance
Our friend Rob from Blackwood Productions often encounters clients, who believe that once you optimize a site, it is done foreve. If you want to be successful, you need to permanently optimize your site, keep an eye on the competition and – changes in the ranking algorithms of search engines.


6. Concentrating too much on meta tags
A lot of people seem to think SEO is about getting your meta keywords and description correct! In fact, meta tags are becoming (if not already) a thing of the past. You can create your meta keywords and descriptions but don't except to rank well only because of this.


7. Using only Images for Headings
Many people think that an image looks better than text for headings and menus. Yes, an image can make your site look more distinctive but in terms of SEO images for headings and menus are a big mistake because h2, h2, etc. tags and menu links are important SEO items. If you are afraid that your h1 h2, etc. tags look horrible, try modifying them in a stylesheet or consider this approach:
http://www.stopdesign.com/articles/replace_text.


8. Ignoring URLs
Many people underestimate how important a good URL is. Dynamic page names are still very frequent and no keywords in the URL is more a rule than an exception. Yes, it is possible to rank high even without keywords in the URL but all being equal, if you have keywords in the URL (the domain itself, or file names, which are part of the URL), this gives you additional advantage over your competitors. Keywords in URLs are more important for MSN and Yahoo! but even with Google their relative weight is high, so there is no excuse for having keywordless URLs.


9. Backlink spamming
It is a common delusion that it more backlinks are ALWAYS better and because of this web masters resort to link farms, forum/newgroup spam etc., which ultimately could lead to getting their site banned. In fact, what you need are quality backlinks. Here are some more information on The Importance of Backlinks


10. Lack of keywords in the content
Once you focus on your keywords, modify your content and put the keywords wherever it makes sense. It is even better to make them bold or highlight them.

From: http://www.webconfs.com/top-10-seo-mistakes-article-24.php

이올린에 북마크하기

happyness WEB/Search Engine

2008/05/24 01:09 2008/05/24 01:09
[로그인][오픈아이디란?]

Flash ImageGallery

2008/05/22 00:56

이번에 이미지 갤러리를 만들어 보기로 했다.

인터넷은 참 대단하다. 나처럼 플래시를 접한지 얼마 되지도 않은 사람에게도 원하는 프로그램을 할 수 있도록 도와주니 말이다.
아직은 이것 저것 많은 것을 알아가야 하지만, 또 다르게 하나 하나 알아가는 재미 또한 쏠쏠하다.

Thumbnail 이미지와 Large 이미지로 구성되는 갤러리 이다.
아직은 MovieClip 정도로 구현하였지만, 로드된 이미지 사이즈가 잘못된 겨우에도 지정된 이미지 사이즈로 표시될 수 있도록, 또한 로딩될때 로딩중 이라고 표시하는 부분을 더 보안할 점 들이다.


Flah image gallery demo
이올린에 북마크하기(0) 이올린에 추천하기(0)

happyness WEB/Flash , ,

2008/05/22 00:56 2008/05/22 00:56
[로그인][오픈아이디란?]

구조와 동작의 분리

2008/05/22 00:52

웹표준에서 말하는 기본적인 철학이 구조와 동작, 표현의 분리이다.
아래 소스는 IE7, FF2에서 테스트 되었다.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Structure와 Behavor의 분리</title>
<link rel="stylesheet" type="text/css" href="style.css" />
<script type="text/javascript" src="onload.js"></script>
<script type="text/javascript">
    //<![CDATA[
        // window.onload 에 함수를 등록한다.
        addOnLoadListener(addCountryEventListener);
       
        /*
         * 지정된 객체의 이벤트를 등록한다.
         * 참조: Document Object Model (DOM) Level 2 Events Specification
         *       http://www.w3.org/TR/2000/REC-DOM-Level-2-Events-20001113/Overview.html
         */
        function addCountryEventListener() {
            var country = document.getElementById('country');
            if (country.addEventListener) {
                // IE가 아닌 경우
                country.addEventListener("change", setCountry, false);
            } else if (country.attachEvent) {
                // IE의 경우
                country.attachEvent("onchange", setCountry);
            }
        }
       
        function setCountry(e) {
            if (!e) var e = window.event;
           
            // IE의 경우 this 오브젝트를 사용할 수 없음.
            var tg = (window.event) ? e.srcElement : e.target;

            // IE의 경우 option value를 생략한 경우 선택한 값이 없으나,
            // FF의 경우 데이터를 가져옴.           
            document.getElementById('form1').selectedCountry.value = tg.options[tg.selectedIndex].value;
        }
    //]]>
</script>
</head>
<body>
<form id="form1" name="form1" method="post" action="">
    <dl>
        <dt>Select Country</dt>
        <dd>
            <select name="country" id="country">
                <option value="Korea">Korea</option>
                <option value="France">France</option>
                <option value="German">German</option>
                <option value="Italy">Italy</option>
            </select>
        </dd>
        <dt>Selected Country</dt>
        <dd>
            <input type="text" name="selectedCountry" id="selectedCountry" />
        </dd>
    </dl>
</form>
</body>
</html>


아래의 파일을 다운받으면 예저를 볼 수 있다.



이올린에 북마크하기(0) 이올린에 추천하기(0)

happyness WEB/XHTML and CSS

2008/05/22 00:52 2008/05/22 00:52
[로그인][오픈아이디란?]

본문에 CSS 정의가 존재하면?

2008/05/22 00:51

웹 페이지를 작성하다보면 BODY 내에 CSS를 정의하는 경우가 많다.
페이지를 여러개로 쪼개는 경우 이런 일이 발생할 소지가 꽤 끄다고 할 수 있다.
하지만, 브라우져의 경우 본문을 파싱하다 정의된 CSS를 만나면 처음부터 다시 파싱한다. (어라 CSS정의가 또 있네? 내가 빼먹은게 있나?)
이럴경우 페이지내의 컨텐츠가 많다면 당연 로딩속도가 느려지게 된다. 많으면 많을 수록 더욱 느려지는 건 당연지사...

아래의 예는 P 태그를 바디 안에서 다시 정의했다. 이경우 전에 나온 P 태그 또한 동일한 스타일 시트가 적용되는 것을 볼 수 있다.


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>CSS 파싱</title>
<style type="text/css">
p {
 font: 2em "Verdana, Arial, Helvetica, sans-serif" bold;
}
</style>
</head>
<body>
<p>first paragraph</p>
<style type="text/css">
 p { border: 1px solid #00F; }
</style>
<p>second paragraph</p>
</body>
</html>


이올린에 북마크하기(0) 이올린에 추천하기(0)

happyness WEB/XHTML and CSS

2008/05/22 00:51 2008/05/22 00:51
[로그인][오픈아이디란?]

UCC에 사용하는 동영상 플레이어 흉내 내기

2008/04/08 01:43
플래시를 이제 막 접하면서 UCC에서 사용하는 동영상 플레이어를 흉내 내보기로 하였다. 목표는 FDS를 사용하지 않는 단순 스트리밍 방식의 플에이어다. 일단 개념을 잡고 인터넷을 뒤지기 시작했다.

Flash streming

ActionScript 3.0은 OOP의 개념을 도입한것 같다-이전 버전은 경험이 없어 어떠한지 모르겠다-. 마치 자바 프로그램을 하는 것 같은 느낌이 들어 어렵지 않게 느껴진다. 그렇지만 이것 이외의 것들은 참 힘들게 느껴진다. 경험이 없으니 당연하겠지만~

도움말, 블로그에 있는 아티클을 읽고 인용하고, 샘플 프로그램을 베끼다 시피 하면서 일부 완성하였다. 이후에 해야 할 것들은 비디오 컨트롤 부분을 컴포넌트화 하는(언제 될지는) 것이 목표이다.

첨부된 파일을 다운받아 소스를 살펴볼 수 있다.


사용예


<embed loop="true" menu="false" quality="high"
width="320" height="240"
type="application/x-shockwave-flash"
pluginspage=
"http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"
src="http://www.htdocs.kr/fmp/swf/fmp1.swf?vid=1234">
</embed>

데모 플래시

이올린에 북마크하기(0) 이올린에 추천하기(0)

happyness WEB/Flash ,

2008/04/08 01:43 2008/04/08 01:43
[로그인][오픈아이디란?]

플래시에서 서버와 통신하기

2008/03/25 17:12

플래시에서 파라메터를 받아 서버와 통신하는 예제이다.
URLRequest와 URLLoader를 이용하여 구현하였다.

메인 소스:

[code]
import flash.events.Event;
import flash.events.IEventDispatcher;
import flash.events.IOErrorEvent;
import flash.events.HTTPStatusEvent;
import flash.events.ProgressEvent;
import flash.events.SecurityErrorEvent;

import flash.net.URLRequestMethod;

import flash.text.TextFieldAutoSize;
import fl.controls.Label;

import com.ericfeminella.collections.IMap;
import com.ericfeminella.collections.HashMap;

import kr.htdocs.net.HTTPRequest;

/* 파라메터를 받음 */
var param1:String = (loaderInfo.parameters.param1 == undefined)
      ? "null" : loaderInfo.parameters.param1;
var param2:String = (loaderInfo.parameters.param2 == undefined)
      ? "null" : loaderInfo.parameters.param2;

/* 넘겨줄 파라메터 셋 만듬 */
var map:IMap = new HashMap(); 
map.put("param1", param1); 
map.put("param2", param2); 

/* 서버에 데이터 요청 */
var xr:HTTPRequest = new HTTPRequest("http://www.htdocs.kr/fmp/flv.php", URLRequestMethod.GET, map);
xr.addEventListener(Event.COMPLETE, completeHandler);
xr.addEventListener(Event.OPEN, openHandler);
xr.addEventListener(ProgressEvent.PROGRESS, progressHandler);
xr.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
xr.addEventListener(HTTPStatusEvent.HTTP_STATUS, httpStatusHandler);
xr.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);

xr.load();

/*
 * 이벤트 핸들러
 */
 
function completeHandler(event:Event):void {
 var loader:URLLoader = URLLoader(event.target);

 /* 텍스트 출력 */
 txResult.text = loader.data;
/*
 var l:Label = new Label();
 l.text = loader.data;
 l.autoSize = TextFieldAutoSize.CENTER;
 l.x = 30;
 l.y = 30;
 addChild(l);
*/
}


function openHandler(event:Event):void {
 txLog.text = txLog.text + "openHandler: " + event;
}

function progressHandler(event:ProgressEvent):void {
 txLog.text = txLog.text + "progressHandler loaded:" + event.bytesLoaded + " total: " + event.bytesTotal;
}

function securityErrorHandler(event:SecurityErrorEvent):void {
 txLog.text = txLog.text + "securityErrorHandler: " + event;
}

function httpStatusHandler(event:HTTPStatusEvent):void {
 txLog.text = txLog.text + "httpStatusHandler: " + event;
}

function ioErrorHandler(event:IOErrorEvent):void {
 txLog.text = txLog.text + "ioErrorHandler: " + event;
}

stop();
[code]

HTTPRequest.as :
[code]
/**
 * Copyright (c) 2008 Young Joo Lee <ifalcon@naver.com>
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */
package kr.htdocs.net {
 import flash.net.URLLoader;
 import flash.net.URLRequest;
 import flash.net.URLRequestMethod;
 import flash.net.URLVariables;
 
 import com.ericfeminella.collections.IMap;

 /**
  * = URLRequest =
  * URLRequest 클래스는 하나의 HTTP 요청에 포함된 모든 정보를 캡처한다.
  * FileReference 클래스의 upload() 및 download() 메서드뿐 아니라 URLStream의 load() 메서드,
  * URL 다운로드를 시작하기 위한 URLLoader, Loader 및 기타 로드 작업에 URLRequest 객체가 전달된다.
  *
  * = URLLoader =
  * URLLoader 클래스는 URL에서 텍스트, 이진 데이터 또는 URL 인코딩된 변수 형식으로 데이터를 다운로드한다.
  * 이것은 텍스트 파일, XML 또는 동적 데이터 기반 응용 프로그램에서 사용되는 기타 정보를 다운로드할 때 유용하다.
  *
  * URLLoader 객체는 모든 데이터를 URL에서 다운로드한 다음 ActionScript에서 사용할 수 있게 한다.
  * 다운로드 진행 상황에 대한 알림을 전송하며, 이 진행 상황은 전달된 이벤트뿐 아니라
  * bytesLoaded 및 bytesTotal 속성을 통해서도 모니터링할 수 있다.
  */
 public class HTTPRequest {
  private var _uri:String;
  private var _method:String;
  private var _args:IMap;
 
  private var _loader:URLLoader;
 
  /**
   * 생성자
   */
  public function HTTPRequest(uri:String, method:String, args:IMap = null) {
   this._uri = uri;
   this._method = method;
   this._args = args;
   
   this._loader = new URLLoader();
  }
 
  /**
   * 이벤트를 등록한다.
   */
  public function addEventListener(type:String, listener:Function):void {
   _loader.addEventListener(type, listener);
  }
 
  /**
   * 지정된 uri로 데이터를 요청한다.
   */
  public function load():void {
   var request:URLRequest = new URLRequest(_uri);
   request.method = (_method == null) ? URLRequestMethod.GET : _method;
   
   /* 전달될 파라메터를 세팅한다. */
   if (_args != null) {
    var nameValuePairs:URLVariables = new URLVariables();
    var keys:Array = _args.getKeys();
    for each(var key:String in keys) {
     nameValuePairs[key] = _args.getValue(key);
    }
    request.data = nameValuePairs;
   }
   
   /* 요청 */
   try {
    _loader.load(request);
   } catch (error:Error) {
    trace("Unable to load requested document.");
   }
  }
 }
}
[/code]

다운로드: flashmovieplayer.zip

데모:


이올린에 북마크하기(0) 이올린에 추천하기(0)

happyness WEB/Flash ,

2008/03/25 17:12 2008/03/25 17:12
[로그인][오픈아이디란?]