본문 바로가기

Javascript

(81)
Child WIndow가 닫혔는지 조사하기 먼저 child window가 열려있다가 가정합니다. win = window.open(...); 다음은 setInterval로 0.1초마다 Child WIndow가 살아있는지 체크하니다. var timer, win; function polling(){ if (win && win.closed) { clearInterval(timer); alert('popup window is closed.'); } } timer = setInterval('polling()',100);
Refresh Javascript 자기 자신을 갱신하기 위한 스크립니다. location.reload(true); 위와 같이 쓰면 자신의 페이지를 리로드 한다.
Nested Elements 선택하기 … … … … 위의 코드가 있다가 가정합니다. 이때 emailContainer에 있는 panel들을 가져올때 방법중 하나를 소개하고자 합니다. var emailDiv = $('#emailContainer'); 위와 같이 emailContainer 요소를 가져옵니다. 그다음 Jquery의 find()메서드를 사용하여 아래와 같이 합니다. var panels = emailDiv.find('div.panel'); 두번째 방법은 아래와 같이 context 안에 값을 가져오는 방법입니다. var panels = $('div.panel', emailDiv); 참 여러가지 방법이 있네요
테이블에서 체크박스에서 체크된 특별 컬럼들 가져오기 var tds =$('.테이블클래스 tr:has(:checkbox:checked) .td에준클래스'); 위와같이 하면 특정 td값들을 array로 가져올수 있다.
Json Validation하는 사이트 입니다. 프로젝트 하다가 복잡한 Json을 만들어서 넘기는 부분이 있었는데 http://jsonlint.com/ 이 사이트에서 Validation을 하면 됩니다. 휴~~~
Jquery Animate function http://www.viget.com/inspire/fun-with-jquerys-animation-function/# 위의 기사는 animate에 대한 예제를 보여주고 있습니다. 관심있으신 분은 한번 보시면 좋을 듯해요
javascript 한글 인코딩 문제 파라미터를 서버에 보낼때 한글이 깨지는 현상을 종종 봅니다. 그럴때는 escape를 쓰시면 됩니다. escape('한글'); 위와 같이 하시면 됩니다. 서버에서의 HttpUtility.UrlEncode(string)을 쓰시면 됩니다. 감사합니다.
HTML5 Application에서 JsRender Template사용하기 http://weblogs.asp.net/dwahlin/archive/2011/11/23/reducing-javascript-code-by-using-jsrender-templates-in-html5-applications.aspx 위의 기사를 퍼온 글입니다. Back in November of 2010 I wrote a post titled Reducing Code using jQuery Templates that demonstrated how jQuery Templates could be used to reduce significant amounts of JavaScript code. Although the topics and code discussed in that post are still val..