웹마스터 팁





레이어 쪼물딱거리기 - 이번얘기는 레이어안의 내용에 관한겁니다.
레이어 내용에 관한 속성은 innerHTML 이고 이 속성은 읽거나 쓰기가
가능합니다.
이 속성으로 레이어의 내용을 새로 정해주었을때 앞전 내용은 없어져버
리죠.

레이어 안에 1000 개의 글자중에 틀린 글자를 찾아내는 소스입니다.
틀린 글자의 갯수는 최대 열개 최소 한개 사이죠.

비슷한 글자끼리 하나의 배열을 형성하는 다중 배열을 정의해줍니다.
그리고 임의로 이 요소중 하나의 배열을 선택해 첫글자를 중심으로
레이어에 천개의 문자를 뿌려주고......
물론 틀린 글자를 적당히 섞고 또 맞는 글자를 클릭할때와 틀린 글자를
클릭할때 확인해줄 함수도 링크를 걸어줍니다.

제대로 클릭 했을땐 안내문 레이어에 적당한 멧세지를 띄워주며
엉뚱한 글자를 클릭 했거나 찾아낸 글자를 또 클릭했을땐 alert 창을 띄워주죠.
찾기 귀찮을땐 틀린 글자를 빨간 색으로 바꿔주는 함수도 만들어봤습니다.
틀린 글자가 빨간색으로 뜨더라도 기존의 기능은 달라지지 않습니다.


미리 보기 :http://allzza.net/xxx/aboard.php?id=pds&dbf=11&mode=source


<html>
<title>
뽕뽕뽕뽕뽕뿅
</title>
<head>

<style type='text/css'>
   body
    A:link { text-decoration:none;font-size:12pt; color:  #ffffff;}
    A:visited { text-decoration:none;font-size:12pt; color: #ffffff;}
    A:active { text-decoration:none;font-size:12pt; color: #ffffff;}
    A:hover {color: ffffff;font-size:12pt; text-decoration:none;}  
    A  { cursor:crosshair  }

</style>

<script>

/*********************************************
제작 : 미친개(webmaster@allzza.net)
날자 : 04.6.25

공개용이고 수정과 사용 재배포에서 자유롭습니다.
학습용으로 쓰시길 권합니다.
***********************************************/


var strrr = new Array(
      new Array('뷁','붺','쀍','봵'),
      new Array('뽕','뿅','뿡','쁨','쁑'),
      new Array('탕','땅','텅'),
      new Array('가','거','갸','겨','개','걔')
      );
      
random_first = Math.floor(Math.random() * strrr.length);   //-- 다중 배열에서 하나의 배열을 임의로 찾아냄
str = strrr[random_first];

inner_html = '';               //-- 레이어에 뿌려질 문자열
str_length = 1000;      //-- 레이어에 뿌려질 문자열 길이
abc = new Array()     //-- 체크 함수를 위한 배열

  
int_random1 = Math.ceil(Math.random() * 10);   //-- 10 는 틀린 글자의 최대 갯수
int_array = new Array();         //-- 1000 개의 숫자를 요소로 하는 배열
int_array2 = new Array();
p = 0;                         //-- p 는 임의로 추출한 틀린글자 갯수까지.......

   for(m=0;m<int_random1;m++)  {
       push_int = Math.floor(Math.random() * str_length);
       if(in_array(push_int,int_array2))  m--;
       else int_array2.push(push_int);
       p = int_array2.length;
       //document.all.bbb.innerHTML = '총' + p + '개의 틀린글자가 있습니다';
       }

   for(n=0;n<str_length;n++)   {
       if(in_array(n,int_array2))  int_array[n] = Math.floor(Math.random() * (str.length - 1)) + 1;
       else int_array[n] = 0;
       }

function make_int1(flag)  {         //-- 레이어에 글자를 뿌려줌
   document.all.bbb.innerHTML = ''' + str[0] + ''이 아닌 글자가 총' + p + '개 있습니다';
    
   make_int2(flag);
   document.all.aaa.innerHTML = inner_html;
   }
    
function make_int2(ddd)   {          //-- 틀린 글자를 빨간 글자로 바꿔 레이어에 뿌려줌
   inner_html = '';
   if(!ddd)  {
           for(b=0;b<str_length;b++)  {
               if(int_array[b] == 0) inner_html += '<a href='javascript:click(' + b + ')'>' + str[int_array[b]] + '</a>';
               else inner_html += '<a href='javascript:click(' + b + ')' id=ccc>' + str[int_array[b]] + '</a>';  
               if(b % 40 == 39) inner_html += '<br>';
               }
          }
   else  {
       for(b=0;b<str_length;b++)  {
             if(int_array[b] == 0) inner_html += '<a href='javascript:click(' + b + ')'>' + str[int_array[b]] + '</a>';
             else inner_html += '<a href='javascript:click(' + b + ')'><font color=red><b>' + str[int_array[b]] + '</b></font></a>';  
             if(b % 40 == 39) inner_html += '<br>';
             }
       }
   }
    
function click(su)  {          //-- 글자를 클릭 했을때 실행 하는 함수
   if(in_array(su,int_array2))   {
       if(!check(su))  {
               abc.push(su);
               p -= 1;
               if(p != 0) document.all.bbb.innerHTML = p + '개 남았습니다';
               else  {
                   document.all.bbb.innerHTML =  '다 찾았습니다';
                   alert('다 찾으셨네요. nn근데 뭐할라고 찾으셨우??');
                   }
               }
       else  alert('아까 찾은 글자인데요');
       }
   else alert('아닌데요');
   }
  
function in_array(fu,array_name)   {    //-- 배열에 배열 요소가 있나 확인해주는 함수
   in_flag = false;
   //array_name = array_na;
   for(k=0;k<array_name.length;k++)  {
       if(fu == array_name[k]) in_flag = true;
       //break;                //-- 이 구문을 실행 시키니 원하는대로 결과가 나오질 않네.
       }
   return in_flag;
   }
  
function check(num)   {   //-- 클릭한 글자를 다시 클릭 했을때
  //abc = new Array();
  if(in_array(num,abc)) return true;
  else return false;
  }
  
</script>

<body onload='javascript:make_int1(0)' bgcolor=222222>

<input type=button value='+ '게임 하기 또는 다시 시작하기 또는 매우매우 심심하기' onclick='javascript:location.reload()'>
<input type=button value='찾기 졸라 귀찮기' onclick='javascript:make_int1(1)'>


<div id=aaa style='position:absolute;left:100;top:150;width:700;height:500;background-color:555555;font:12pt;color:white;padding-left:30;padding-top:20;cursor:crosshair'>
</div>

<div id=bbb style='position:absolute;left:100;top:50;width:700;height:50;background-color:555555;font:12pt;color:white;padding-left:30;padding-top:20;cursor:crosshair'>
</div>
제목 글쓴이 날짜
로딩 100% 후 페이지 이동시키기 [1] ▩윤미 2004.04.30
웹페이지에 테두리 두르기 [5] ▩윤미 2004.04.30
그림파일없이 바꾸는 그라이데이션 배경색 [3] ▩윤미 2004.04.30
접속할때마다 다른 이미지 띄우기 [8] ▩윤미 2004.04.30
특정위치에 떠있는 레이어 (슬라이딩 애드콘) - 노프레임홈에서의 문제해결 [8] 검미르 2004.05.03
상태창에 머문시간 보여주기 [5] ☺심심 2004.05.05
클릭하거나, 바탕을 더블클릭하면 나타나는 작은(크기조절가능) 메뉴 ☺심심 2004.05.17
이미지 갤러리-이미지에 설명이나 이름을 같이 달아줄수 있는.. webzang 2004.05.17
배너를 모자이크로 슬라이드한다! [13] ☺심심 2004.05.17
동영상을 일반 버튼으로 제어 ☺심심 2004.05.23
왔다 갔다 이미지 스크롤 [3] 컴도미 2004.05.25
간단한 감추기/펼치기 스크립트 (태터툴즈의 more 기능) [5] 나이시스 2004.05.28
지바 애플 아날로그 시계 소스입니다... [4] 한성민 2004.06.02
[StylishJAVA]레이어를 이용한 슬라이드 메뉴 [5] ∑Ztxy 2004.06.05
[추천] 가로형 배너 슬라이드 [7] file ⓣinⓣin™ 2004.06.10
볼륨값이 얼마나 될까? [5] PHASE 2004.06.16
[추천] 세로형 배너 슬라이드 [4] ⓣinⓣin™ 2004.06.24
둥근테이블을 홈피에 짜고싶을때../ [12] file zEn 2004.06.28
레이어 특강 1 - 큰일 나는 소스 [23] 미친개 2004.06.30
레이어 2 - 뷁뷁뷁뷁뷁봵 [7] 미친개 2004.07.04