var his = new Array();   

Element.prototype.attachEvent = function(a,b){
        his.push(this.tagName+ ":"+a+":"+b);       
    }


function test(){
        for(var i = 0; i < his2.length; i ++){
            alert(his[i]);
        }
    }

대충 이런느낌? 대신 attachEvent한건 싹다날라간다
ie기준으로 작성..나중에 실무에서 디버깅할때 써먹어봐야지
Posted by 삽지리
,
참조 : http://www.quirksmode.org/dom/innerhtml.html
http://www.slideshare.net/joone/ss-9766705
http://firejune.com/1174

내용을 정리해보면
일부브라우저에서는 innerHTML 이 더 괜찮은 속도를 낼수 있다. 예를들어 ie6,7의 경우에는
dom mehtod를 통한 컨트롤은 아주 느리다.
그렇지만 http://firejune.com/1174 의 결과에 따르면 엘리먼트 숫자가 늘어날수록 dom method를 통한 컨트롤이 더 나은 형향을 미치는것을 알수 있다.

특히 괄목할만 한 점은 노드를 innerHTML로 없애버리는것은 확실히 느리다는것을 알수 있다.

Posted by 삽지리
,
출처 : http://www.williammalone.com/articles/create-html5-canvas-javascript-drawing-app/

핵심은

$(window).scroll(
        function ()
        {
            if($(window).scrollTop() > $("#content").position().top + 20){
                $("#tableOfContents").css("position", "fixed");
                var marginTop = 20;// - $("#content").height();
                /*$("#tableOfContents").css("margin-top", marginTop + "px");*/
                $("#tableOfContents").css("top", "0");
            }else{
                $("#tableOfContents").css("position", "static");
                $("#tableOfContents").css("margin-top", "20px");
          }
        }
    );

이부분
Posted by 삽지리
,

utf-8환경에서 작업을 하는데

가끔 javascript 가 euc-kr로 올라가는 경우가 있다.

해당자바스크립트에 한글이 있다면 대략 오류가 뜰떄가 있다.

Posted by 삽지리
,
var obj_x,obj_y,obj_width,obj_height;
   var flag=false;
   var obj;
   function table_resize_start(e,target_id){
    flag=true;
    obj=document.getElementById(target_id);
    if(document.all){
      obj_x=e.clientX;
      obj_y=e.clientY;
      obj_width = obj.style.pixelWidth;
      obj_height = obj.style.pixelHeight;     
    }else if(document.getElementById){    
      obj_x=e.pageX;
      obj_y=e.pageY;
      obj_width = parseInt((obj.style.width).replace("px",""),10);
      obj_height = parseInt((obj.style.height).replace("px",""),10);     
    }  
    obj.style.cursor= "n-resize";      
   }
   function table_resize(e){
   if(flag){
     if(document.all){
      obj_xx=e.clientX-obj_x
      obj_yy=e.clientY-obj_y     
      obj.style.pixelWidth=obj_width + obj_xx;
      obj.style.pixelHeight=obj_height +obj_yy;     
      }
     else if(document.getElementById){
      obj_xx=e.pageX-obj_x
      obj_yy=e.pageY-obj_y     
      objWidth = obj_width+obj_xx;
      objHeight = obj_height+obj_yy;
      obj.style.width=objWidth+"px"
      obj.style.height=objHeight+"px"
      }
     }
   }
   
   function table_resize_end(){
    flag=false;
    obj.style.cursor= "";
   }
Posted by 삽지리
,

ff에서는 잘돌아가는데 ie에서는 잘안된다.

왜일까..

response.contentType도 xml로 했는데

ie에서 responseTEXT를 찍으면 잘나오지만

xml을 가져오면 제대로 못가져온다.

그런데..

문서의 상단에 <?xml version="1.0" encoding="euc-kr;" ?>을

정의하니까 잘되더라.

그때그떄마다 경우가 달라서 혼란스럽다..

 

갑자기 안돼서 삽펐다

 

<?xml version="1.0" encoding="euc-kr;" ?> 알고보니

euc-kr뒤에 ;붙어서 안됐네 하놔.

 

<?xml version="1.0" encoding="euc-kr" ?>  이걸로 다시 수정

Posted by 삽지리
,

ajax에서 xml 문서를 컨트롤할때 문서에 정의된것과 상관없이 문서의 contentType이 xml 이어야한다

문서안에 백날 정의해봤자 말짱꽝

 

response.setContentType("text/xml;charset=utf-8");

Posted by 삽지리
,

function selectSort(sortMethod) {
 formSel = document.categoryForm.CatItem;

 if(!formSel.value) return;

 thisIndex = formSel.selectedIndex;

 if(sortMethod == "down") { //다운일때
  if(thisIndex+1 >= formSel.length) return;
  formSel.value = null;
  prevIndex = thisIndex + 1;
 }
 else { //업일때
  if(!thisIndex) return; 
  formSel.value = null;
  prevIndex = thisIndex-1;
 }

 tempText = formSel.options[prevIndex].text;
 tempValue = formSel.options[prevIndex].value;

 formSel.options[prevIndex] = new Option(formSel.options[thisIndex].text,formSel.options[thisIndex].value);

 formSel.options[thisIndex] = new Option(tempText,tempValue);

 formSel.value = formSel.options[prevIndex].value; 
}

function updateSort() {
 var oForm = document.categoryForm;

 formSel = document.categoryForm.CatItem;

 res = new Array();

    for(var i=0;i<formSel.length;i++) {
  arrayValue = formSel.options[i].value.split("||");

     res[i] = arrayValue[0];
    }

 res = res.join("@");
 oForm.sortItem.value = res;

 if (confirm('카테고리 출력순서를 재정렬 하시겠습니까?')) {
  oForm.runMode.value = "sort";  
  oForm.action="inCateFrame1.asp";
  oForm.submit();
 }
 else {
  return;
 }
}

 

 

대략이런식 키포인트는 updateSort()에서 데이터를 가공해서 보낸다는게 되것다~

 

Posted by 삽지리
,

참조사이트 :

http://tagin.net/bbs/view.php?id=js5&page=5&sn1=&divpage=1&sn=off&ss=on&sc=on&select_arrange=headnum&desc=asc&no=63

 

뭐 참조랄것도 없이 거의 다 배꼈지만..

 

<code>

 

var x,y,w,h;
   var flag=false;
   var obj;
   function table_resize_start(e,target_id){
    flag=true;
    obj=document.getElementById(target_id);
    if(document.all){
     
     
      x=e.clientX;
      y=e.clientY;
      w = obj.style.pixelWidth;
      h = obj.style.pixelHeight;     
    }else if(document.getElementById){    
      x=e.pageX;
      y=e.pageY;
      w = parseInt((obj.style.width).replace("px",""),10);
      h = parseInt((obj.style.height).replace("px",""),10);     
    }  
    obj.style.cursor= "n-resize";      
   }
   function table_resize(e){
   if(flag){
     if(document.all){
      xx=e.clientX-x
      yy=e.clientY-y     
      obj.style.pixelWidth=w + xx;
      obj.style.pixelHeight=h +yy;     
      }
     else if(document.getElementById){
      xx=e.pageX-x
      yy=e.pageY-y     
      objWidth = w+xx;
      objHeight = h+yy;
      obj.style.width=objWidth+"px"
      obj.style.height=objHeight+"px"
      }
     }
   }
   
   function table_resize_end(){
    flag=false;
    obj.style.cursor= "";
   }

 

</code>

Posted by 삽지리
,

//addec by mj.chong 2006.12.06
//tag 금칙 문자 (%, &, +, <, >, ?, /, \, ', ", =,  \n)
//comma는 별로도 제외하는 로직이 있음
var restrictedTagChars = /[\x25\x26\x2b\x3c\x3e\x3f\x2f\x5c\x27\x22\x3d]|(\x5c\x6e)/g;

 

function validTag(tagObj, e)
{
 var tagVal = tagObj.value;
 var commacnt = 0;
 var key = window.event ? e.keyCode : e.which;
 
 if(tagVal.charAt(tagVal.length-1) == ',' && (key == 44 || key == 32))
  return false;
 for(var i=0; i < tagVal.length; i++) {
  if(tagVal.charAt(i) == ',') {
   commacnt++;
  }
  if(commacnt >= 9) {
   alert("태그는 최대 10개까지 입력할 수 있습니다.");
    return false;
   }
 }
 
 if (key != 0x2C && (key > 32 && key < 48) || (key > 57 && key < 65) || (key > 90 && key < 97))
  return false;
}

 function check_tagvalidate(aEvent, input)
 {
  
  var keynum;
  if(typeof aEvent=="undefined") aEvent=window.event;
  if(IE)
  {
   keynum = aEvent.keyCode;
  }
  else
  {
   keynum = aEvent.which;
  }
  //edited by mj.chong 20061206
  //if(keynum == 188 ) {
  // input.value = BlogTag.validateTagString(input.value);
  //}
  //  %, &, +, -, ., /, <, >, ?, \n, \ |
  var ret = input.value;
  if(ret.match(restrictedTagChars) != null ) {
    ret = ret.replace(restrictedTagChars, "");
    input.value=ret;
  }
  //콤마가 연속으로 있으면 하나로 만든다.
  re = /[\x2c][\x2c]+/g;
  if(ret.match(re) != null ){
   ret = ret.replace(re, ",");
   input.value=ret;
  }
  highlightMyTag();  

 }

 function check_tagsvalidate(input)
 {
  input.value = BlogTag.validateTagString(input.value);

  //중복되는 태그 제거
  input.value = BlogTag.eliminateDuplicate(input.value);

  var tagcount = BlogTag.length(input.value);
  highlightMyTag();
  //태그 수 제한
  if(tagcount > 10)
  {
   alert("태그는 최대 10개 까지 입력이 가능합니다.");
   input.value = BlogTag.absoluteTagString(input.value, 10);   
   input.focus();
   
   return;
  }
  

  //태그의 길이 제한
  var bvalidate;
  var tagmaxlength = 100;
  bvalidate = BlogTag.isValidateTagLength(input.value, tagmaxlength);

  if(!bvalidate)
  {
   alert("태그는  100자 이상 입력할 수 없습니다.");
   input.focus();
   return;
  }
 }

var BlogTag =
{
 //유효한 태그명인지 확인.
 isTagname : function(tagname)
 {
  return tagname.match(restrictedTagChars)==null;
 }
 ,

 //태그 문자열을 유효하게 만든다.( 금지문자 제거, 연속되는 컴마 제거 )
 validateTagString : function(tagstring)
 {
  var ret = tagstring.replace(restrictedTagChars, "");

  //콤마가 연속으로 있으면 하나로 만든다.
  re = /[\x2c]+/g;
  return ret.replace(re, ",");
 }
 ,
 
 absoluteTagString : function(tagstring, maxcnt)
 {
  var valitags = BlogTag.validateTagString(tagstring);
 
  var arraytag = valitags.split(",");
  
  var tagnames = "";

  var absolutecnt = arraytag.length;
  if(absolutecnt > maxcnt)
   absolutecnt = maxcnt;
   
  for(var i=0; i< absolutecnt; i++)
  {
   tagnames = tagnames + arraytag[i] + ",";
  }
  tagnames = BlogTag.validateTagString(tagnames);
  
  tagnames = tagnames.substring(0, tagnames.length-1);

  return tagnames; 
 }
 ,

 //중복되는 태그를 없앤다.
 eliminateDuplicate : function(tagstring)
 {
  var valitags = BlogTag.validateTagString(tagstring);
 
  var arraytag = valitags.split(",");
  
  var tagnames = "";
  
  for(var i=0; i<arraytag.length; i++)
  {
   for(var j=0; j<i; j++)
   {
    //이미 존재 하는 태그라면 없앰.
    if(arraytag[j]==arraytag[i])
    {
     arraytag[i]="";
    }
   }

   tagnames = tagnames + arraytag[i] + ",";
   
  }
  tagnames = BlogTag.validateTagString(tagnames);
  
  tagnames = tagnames.substring(0, tagnames.length-1);

  return tagnames;

 }
 ,

 //태그수 를 계산 한다.
 length : function(tagstring)
 {
  var arraytag = tagstring.split(",");
 
  return arraytag.length;
 }
 ,

 //각 태그의 길이를 특정 크기 이하로 제한한다.
 validateTagLength : function(tagstring, maxlen)
 {
  var arraytag = tagstring.split(",");
  var tagnames = '';

  for(var i=0; i<arraytag.length; i++)
  {
   if(arraytag[i].length > maxlen)
   {
    arraytag[i] = arraytag[i].substring(0, maxlen);
   }
   tagnames = tagnames + arraytag[i] + ",";
  }

  tagnames = tagnames.substring(0, tagnames.length-1);

  tagnames = BlogTag.eliminateDuplicate(tagnames);

  return tagnames;
 }
 ,

 //각 태그의 길이가 유효한지 확인한다.
 isValidateTagLength : function(tagstring, maxlen)
 {
  var arraytag = tagstring.split(",");

  for(var i=0; i<arraytag.length; i++)
  {
   if(arraytag[i].length > maxlen)
   {
    return false;
   }
  }

  return true;
 }
}

Posted by 삽지리
,