<body onunload="alert('안녕~!')">

다른 페이지로 이동하거나 브라우저를 닫으면 경고창이 뜹니다.
Posted by 달팽이맛나
,


<a href="http://tokigui.tistory.com" onfocus="this.blur()" ><img src="tokigui.gif" /></a>

링크 걸린 이미지를 클릭시 점선모양의 테두리가 생기는데 깔끔한 링크를 만들기 위해서,
점선을 없앨때 사용
Posted by 달팽이맛나
,


<script type="text/javascript">
<!--
function openAlert(){
alert("HI! TOKIGUI!");
}
// -->
</script>

<input type="button" onclick="setTimeout('openAlert()',5000)">
클릭후 5초후 경고창이 실행 (1000 = 1초)

Posted by 달팽이맛나
,

<a href="javascript:void(0);" onclick="document.execCommand('SaveAs',true,'file.php');">현재 페이지 저장</a>
Posted by 달팽이맛나
,

<a href="javascript:window.print();">현재 페이지 프린트</a>
Posted by 달팽이맛나
,




document.writeln("브라우저의 전체 높이",screen.availHeight); //(해상도 설정된 최대 높이 - 퀵런치)
document.writeln("브라우저의 전체 너비",screen.availWidth); //(해상도  설정된 최대 너비 - 퀵런치)

document.writeln("모니터의 해상도 높이 ",screen.height); //해상도  설정된 최대 높이
document.writeln("모니터의 해상도 너비 ",screen.width);//해상도  설정된 최대 너비

document.writeln("브라우저 안쪽의 높이 ",document.body.clientHeight); // 떠 있는 브라우저 현재 안쪽의 높이
document.writeln("브라우저 안쪽의 너비 ",document.body.clientWidth); // 떠 있는 브라우저 현재 안쪽 너비

Posted by 달팽이맛나
,

<script type="text/javascript">

 var openPop = window.open ('http://tokigui.tistory.com','','width=500,height=500,left=0, top=0, scrollbars=no, resizable=no');
 if (!openPop) {
  alert("팝업이 차단되었습니다. 팝업을 허락해 주세용~ 네~~~!! ");
 }
</script>

팝업창이 차단되어 있으면 alert창이 뜬다.
Posted by 달팽이맛나
,

<script type="text/javascript">

function idcheck (str) {

 if (str.length < 5 || str.length > 15) { //갯수체크
  alert ("아이디는 4 ~ 15자 사이 영문 및 숫자.");
  return false;
 }else{

  for( var i = 0; i <= str.length -1 ; i++ ) { //영문,숫자체크
   if ( !( ("a" <= str.charAt(i) && str.charAt(i) <= "z") || (str.charAt(i) >= "0" && str.charAt(i) <= "9") ) ) {
    alert ("아이디는 5 ~ 15자 사이의 영문 및 숫자이어야 합니다.");
    return false;
   }
  }
  return true;
 }
}
</script>

Posted by 달팽이맛나
,

<script type="text/javascript">
var max_row_num=10; //row max값
var cur_row_num=1;   //현재 row 갯수
var max_col_num=10; //col max값
var cur_col_num=2;   //현재 col 갯수

function ftnRowAdd(tname) {

 if (max_row_num <= cur_row_num){
  alert("최대갯수(" + max_row_num + ") 초과!!");
  return false;
 } else {
  var objTbl = document.getElementById(tname);
  var objRow = objTbl.insertRow(objTbl.rows.length); //rows add
  var objCell;
  var cell_no = 0;
  cur_row_num += 1;

  for(var i=1 ; i<=objTbl.rows[0].cells.length ; i++) {
   objCell = objRow.insertCell(cell_no); //cells add
   objCell.innerHTML += "<div>" + cur_row_num + "-" + i + "</div>";
   //cell style 셋팅
   objCell.width = "40";
   objCell.height= "15";
   objCell.align = "center";
   objCell.valign= "middle";
   cell_no ++;
  }
 }
}

function ftnCellAdd(tname) {
 var objTbl = document.getElementById(tname);
 var objCell;
 var cell_no = cur_col_num;

 if (max_col_num <= cur_col_num){

  alert("최개갯수(" + max_col_num + ") 초과!!");
  return false;

 } else {
  cur_col_num += 1;
  for(var i=1 ; i<=objTbl.rows.length ; i++) {
   objCell = objTbl.rows[i-1].insertCell(cell_no);
   objCell.innerHTML += "<div>" + i + "-" + cur_col_num + "</div>"
   objCell.width = "40";
   objCell.height= "15";
   objCell.align = "center";
   objCell.valign= "middle";
  }
 }
}

function ftnRowDel(tname) {

 var objTbl = document.getElementById(tname);

 if (cur_row_num < 2){

  alert("1개 이상은 존재해야함!!");
 
 } else {

  objTbl.deleteRow(cur_row_num-1);
  cur_row_num --;

 }
}

function ftnCellDel(tname) {
 var objTbl = document.getElementById(tname);
 var objCell, objRow;

 if (cur_col_num < 2){
  alert("1개 이상은 존재해야함!!");
  return false;
 } else {
  for(var i=1 ; i<=objTbl.rows.length ; i++) {
   objRow = objTbl.rows[i-1];
   objCell = objRow.cells[cur_col_num-1];
   objRow.removeChild(objCell);
  }
  cur_col_num --;
 }
}
</script>
</head>

<input type=button name=btnAddRow value="+행추가" onclick="ftnRowAdd('ctable');" />
<input type=button name=btnAddCol value="+열추가" onclick="ftnCellAdd('ctable');" />
<input type=button name=btnDelRow value="-행삭제" onclick="ftnRowDel('ctable');" />
<input type=button name=btnDelCol value="-열삭제" onclick="ftnCellDel('ctable');" />

<table border="1" id="ctable">
<tr>
 <td width="40" height="15" align="center"><div>1-1</div></td>
 <td width="40" height="15" align="center"><div>1-2</div></td>
</tr>
</table>

Posted by 달팽이맛나
,
<a href="#" onClick="MyWindow=window.open('http://tokigui.tistory.com','MyWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=600,height=300,left=0,top=0'); return false;">
팝업띄우기</a>
Posted by 달팽이맛나
,