<!--- setCookie & getCookie --!>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Script-Type" content="text/html; charset=euc-kr" />
<title>Cookie 방식 동작 확인-Title-</title>
</head>
<body>
<pre>
<script type="text/javascript">
//<!--
//?id=12345&category=javascript
document.writeln();
// 크롬 부라우져에선 제대로 동작하지 않음, 원인 분석 필요.
function setCookie(name, value, expires, domain, path, secure) {
var c = '';
c += name + '=' + encodeURIComponent(value);
if(expires) {
var exp = new Date();
exp.setDate(exp.getDate() + expires);
c += '; expires=' + exp.toGMTString();
}
if(domain) {
c += '; domain=' + domain;
}
if(path) {
c += '; path=' + path;
}
if(secure) {
c += '; secure=' + secure;
}
document.cookie = c;
}
function getCookie(name) {
var cs = document.cookie.split(';');
for(var i=0; i<cs.length; i++) {
var kv = cs[i].split('=');
if(kv[0] == name) {
return decodeURIComponent(kv[1]);
}
}
}
var cnt = getCookie('www_awesome_com_popup_today');
cnt = cnt ? ++cnt : 1;
setCookie('www_awesome_com_popup_today', cnt, 90);
document.write('당신은 이 사이트에 ' + cnt + '회, 액세스하였습니다.');
//--!>
</script>
<noscript>JavaScript를 사용할 수 없습니다.. </noscript>
</pre>
</body>
</html>
<!-- 웹브라우져 정보 보기 -->
<script type="text/javascript">
//<!--
//?id=12345&category=javascript
document.writeln();
var viewBrowserInfo = function() {
document.writeln(navigator.appCodeName);
document.writeln(navigator.appName);
document.writeln(navigator.appVersion);
document.writeln(navigator.platform);
document.writeln(navigator.userAgent);
document.writeln(navigator.javaEnabled());
};
viewBrowserInfo();
//--!>
</script>
<noscript>JavaScript를 사용할 수 없습니다.. </noscript>
<!-- 파라메터 쿼리 -->
<script type="text/javascript">
//<!--
//?id=12345&category=javascript
function $q() {
var result = {};
var str = location.search.substring(1);
var params = str.split('&');
for(var i=0; i<params.length; i++) {
var kv = params[i].split('=');
result[kv[0]] = decodeURIComponent(kv[1]);
}
return result;
}
document.writeln();
var q = $q();
document.writeln('id:' + q['id']);
document.writeln('category:' + q['category']);
//--!>
</script>
<noscript>JavaScript를 사용할 수 없습니다.. </noscript>
<!-- 노드 추가 -->
<pre>
<script type="text/javascript">
//<!--
//?id=12345&category=javascript
document.writeln();
function add(f) {
var anchor = document.createElement('a');
anchor.href = f.url.value;
var name = document.createTextNode(f.name.value);
anchor.appendChild(name);
var br = document.createElement('br');
var list = document.getElementById('list');
list.appendChild(anchor);
list.appendChild(br);
}
//--!>
</script>
<noscript>JavaScript를 사용할 수 없습니다.. </noscript>
</pre>
<form>
<label>사이트 명:<br />
<input type='text' name='name' size='30' /></label><br />
<label>URL:<br />
<input type='text' name='url' size='50' /></label><br />
<input type='button' value='추가' onclick='add(this.form)'>
</form>
<div id='list'></div>
<!-- jquery 이용 샘플 코드 -->
<div id="list">
<table boder='0'>
<tr>
<td><img src="http://www.wings.msn.to/books/978-4-7981-2205-2/978-4-7981-2205-2.jpg" height="150" width="108" /></td>
<td><img src="http://www.wings.msn.to/books/978-4-7741-4076-6/978-4-7741-4076-6.jpg" height="150" width="108" class="gihyo" /></td>
<td><img src="http://www.wings.msn.to/books/978-4-8443-2879-7/978-4-8443-2879-7.jpg" height="150" width="108" /></td>
<td><img src="http://www.wings.msn.to/books/978-4-7741-4223-4/978-4-7741-4223-4.jpg" height="150" width="108" class="gihyo" /></td>
<td><img src="http://www.wings.msn.to/books/978-4-8443-2865-0/978-4-8443-2865-0.jpg" height="150" width="108" /></td>
</tr>
</table>
</div>
<script type="text/javascript" src="scripts/jquery-1.5.1.js"></script>
<script type="text/javascript">
<!--
$('#list img.gihyo').animate({height:200, width:140}, 500);
$('<img src="http://www.wings.msn.to/image/wings.jpg" />').appendTo('body');
$(document.body).css('backgroundColor', '#33ff66');
//--!>
</script>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Script-Type" content="text/html; charset=euc-kr" />
<title>Cookie 방식 동작 확인-Title-</title>
</head>
<body>
<pre>
<script type="text/javascript">
//<!--
//?id=12345&category=javascript
document.writeln();
// 크롬 부라우져에선 제대로 동작하지 않음, 원인 분석 필요.
function setCookie(name, value, expires, domain, path, secure) {
var c = '';
c += name + '=' + encodeURIComponent(value);
if(expires) {
var exp = new Date();
exp.setDate(exp.getDate() + expires);
c += '; expires=' + exp.toGMTString();
}
if(domain) {
c += '; domain=' + domain;
}
if(path) {
c += '; path=' + path;
}
if(secure) {
c += '; secure=' + secure;
}
document.cookie = c;
}
function getCookie(name) {
var cs = document.cookie.split(';');
for(var i=0; i<cs.length; i++) {
var kv = cs[i].split('=');
if(kv[0] == name) {
return decodeURIComponent(kv[1]);
}
}
}
var cnt = getCookie('www_awesome_com_popup_today');
cnt = cnt ? ++cnt : 1;
setCookie('www_awesome_com_popup_today', cnt, 90);
document.write('당신은 이 사이트에 ' + cnt + '회, 액세스하였습니다.');
//--!>
</script>
<noscript>JavaScript를 사용할 수 없습니다.. </noscript>
</pre>
</body>
</html>
<!-- 웹브라우져 정보 보기 -->
<script type="text/javascript">
//<!--
//?id=12345&category=javascript
document.writeln();
var viewBrowserInfo = function() {
document.writeln(navigator.appCodeName);
document.writeln(navigator.appName);
document.writeln(navigator.appVersion);
document.writeln(navigator.platform);
document.writeln(navigator.userAgent);
document.writeln(navigator.javaEnabled());
};
viewBrowserInfo();
//--!>
</script>
<noscript>JavaScript를 사용할 수 없습니다.. </noscript>
<!-- 파라메터 쿼리 -->
<script type="text/javascript">
//<!--
//?id=12345&category=javascript
function $q() {
var result = {};
var str = location.search.substring(1);
var params = str.split('&');
for(var i=0; i<params.length; i++) {
var kv = params[i].split('=');
result[kv[0]] = decodeURIComponent(kv[1]);
}
return result;
}
document.writeln();
var q = $q();
document.writeln('id:' + q['id']);
document.writeln('category:' + q['category']);
//--!>
</script>
<noscript>JavaScript를 사용할 수 없습니다.. </noscript>
<!-- 노드 추가 -->
<pre>
<script type="text/javascript">
//<!--
//?id=12345&category=javascript
document.writeln();
function add(f) {
var anchor = document.createElement('a');
anchor.href = f.url.value;
var name = document.createTextNode(f.name.value);
anchor.appendChild(name);
var br = document.createElement('br');
var list = document.getElementById('list');
list.appendChild(anchor);
list.appendChild(br);
}
//--!>
</script>
<noscript>JavaScript를 사용할 수 없습니다.. </noscript>
</pre>
<form>
<label>사이트 명:<br />
<input type='text' name='name' size='30' /></label><br />
<label>URL:<br />
<input type='text' name='url' size='50' /></label><br />
<input type='button' value='추가' onclick='add(this.form)'>
</form>
<div id='list'></div>
<!-- jquery 이용 샘플 코드 -->
<div id="list">
<table boder='0'>
<tr>
<td><img src="http://www.wings.msn.to/books/978-4-7981-2205-2/978-4-7981-2205-2.jpg" height="150" width="108" /></td>
<td><img src="http://www.wings.msn.to/books/978-4-7741-4076-6/978-4-7741-4076-6.jpg" height="150" width="108" class="gihyo" /></td>
<td><img src="http://www.wings.msn.to/books/978-4-8443-2879-7/978-4-8443-2879-7.jpg" height="150" width="108" /></td>
<td><img src="http://www.wings.msn.to/books/978-4-7741-4223-4/978-4-7741-4223-4.jpg" height="150" width="108" class="gihyo" /></td>
<td><img src="http://www.wings.msn.to/books/978-4-8443-2865-0/978-4-8443-2865-0.jpg" height="150" width="108" /></td>
</tr>
</table>
</div>
<script type="text/javascript" src="scripts/jquery-1.5.1.js"></script>
<script type="text/javascript">
<!--
$('#list img.gihyo').animate({height:200, width:140}, 500);
$('<img src="http://www.wings.msn.to/image/wings.jpg" />').appendTo('body');
$(document.body).css('backgroundColor', '#33ff66');
//--!>
</script>
댓글
댓글 쓰기