input type=file에서 value 속성 컨트롤하기
      데니스
(kidoel)님의 블로그 http://blog.naver.com/kidoel/20036723580
-->가보면 알겠지만..innerHTML를 이용해서 file폼을 새로그려주는 방식.



type="file" 의 value값 지우기

<script language="javascript">
function valueRemove() {
    frm.file_nm.select();
    document.execCommand('Delete');
}
</script>
<form name="frm">
<input type="file" name="file_nm"><br><br>
<input type="button" value="값지우기" onclick="valueRemove()">
</form>

-->난 select까지는 먹는데 이상하게 delete가 안먹네..이방법이 편해보이는데..ㅠㅠ
출처 :
에버리치(aceseol) 님의 블로그  http://blog.naver.com/aceseol/100033628971
Posted by 귀찮은 여니씨
,

이미지 리사이즈

JavaScript 2008. 3. 10. 00:37

/*--------------------------------------------
마우스로 이미지크기 변경하기
---------------------------------------------*/
<span contentEditable><img src="http://www.ihelpers.co.kr/programming/css/pic.jpg"></span>

출처 : http://sir.co.kr/bbs/board.php?bo_table=pl_dhtml_javascript&wr_id=520&page=4


/*--------------------------------------------
이미지 리사이즈  01
---------------------------------------------*/
function resizeImg(imgObj, max_width, max_height){

 var dst_width;
 var dst_height;
 var img_width;
 var img_height;

 img_width = parseInt(imgObj.width);
 img_height = parseInt(imgObj.height);

 if(img_width == 0 || img_height == 0){
  imgObj.style.display = '';
  return false;
 }

    // 가로비율 우선으로 시작
    if(img_width > max_width || img_height > max_height) {
        // 가로기준으로 리사이즈
        dst_width = max_width;
        dst_height = Math.ceil((max_width / img_width) * img_height);

        // 세로가 max_height 를 벗어났을 때
        if(dst_height > max_height) {
   dst_height = max_height;
   dst_width = Math.ceil((max_height / img_height) * img_width);
        }

        imgObj.width = dst_width;
        imgObj.height = dst_height;
    }
    // 가로비율 우선으로 끝

 imgObj.style.display = '';

 return true;
}

출처 : http://blog.naver.com/tppsc?Redirect=Log&logNo=60013576412


/*--------------------------------------------
이미지 리사이즈 02
---------------------------------------------*/

<body>

<img name=i0 src="http://kr.img.blog.yahoo.com/ybi/1/8c/75/kiseke/folder/3338845/img_3338845_1238887_0?1112168382.jpg" onload=setD(500,0) onclick=vuD();>

<script>


 io=new Array(); //이미지객체의 크기를 담을 배열


 function vuD(){ //이미지를 클릭하면 새창을 띄워 원래의 크기로 보여준다.

  e=event.srcElement;

  var w=io[e.name].w; //이미지 객체의 너비

  var h=io[e.name].h; //이미지 객체의 높이


  test=window.open('','tst','width='+w+',height='+h); //새창을 이미지의 크기만큼 열고

  test.document.write("<body topmargin=0 leftmargin=0 background="+e.src+" onclick=self.close()>"); //새창에 배경으로 그림을 뿌림

 }


 function setD(wd,ht){

  e=event.srcElement; //함수를 호출한 이미지객체


  var w=e.width; //너비

  var h=e.height; //높이


  io[e.name]=new Object(); //새로운 오브젝트 생성

  io[e.name].w=e.width; //너비와,

  io[e.name].h=e.height; //높이를 지정


  if(w>wd){ //너비가 한계치보다 크면

   h/=w/wd; //높이 재설정

   w=wd; //너비 재설정

  }

  e.width=w; //너비 갱신

  e.height=h; //높이 갱신

 }

</script>

출처 : http://blog.naver.com/soul3532/100021699271

Posted by 귀찮은 여니씨
,

01. 팝업창의 Head태그 안에 다음 스크립트를 넣으세요.

<script language="JavaScript" type="text/JavaScript">

<!--
function linkToOpener(URL){
if (window.opener && !window.opener.closed)
window.opener.location = URL;
window.close();
}
//-->
</script>


02. 다음과 같은 방식으로 팝업창에서 링크 설정

a href="javascript:linkToOpener('링크주소');"

윈도우 창과 다른 창과의 통신은 name속성으로 하게 되어 있습니다. 예를 들어 창을 띄울때 window.open("경로명", "윈도우이름");에서 윈도우 이름이 새롭게 만들어진 창의 이름이 됩니다. 그리고 이때 새로운 창을 만든 부모창을 opener window라고 합니다. 따라서 새로운 창과 부모창 간의 통신은 open window와 opener window간의 것이 되는 거죠.

스크립트를 보시면
window.opener && !window.opener.closed - 부모창이 존재하고 닫혀있지 않을때
window.opener.location - 부모창에서 이동할 주소
window.close(); - 창닫기

즉, 부모창이 존재하면 부모창에서 URL로 이동하고 열려 있는 창은 닫는다. 만약 부모창이 존재하지 않으면 팝업창은 그냥 닫혀 버립니다.


- 출처 : 지식인에서 soiyeon님의 답변 -
http://kin.naver.com/db/detail.php?d1id=1&dir_id=109&eid=zoGvuyHvmR50NZZqS+CzKxSZey/+3XKV&qb=xsu+97i1xak=


** 추가하자면 팝업창에서 부모창을 리로드 시키고자 할 때
    opener.parent.window.location.reload();
   
** 팝업창에서 또 팝업창이 열렸을 경우 최하단의 웹페이지 리르드 시키고자 할 때
    opener.opener.parent.window.location.reload();



Posted by 귀찮은 여니씨
,