반응형

1. 부모창 필드 값 가져오기

opener.document.getElementById( "hidValue" ).value;

$( "#hidValue", opener.document ).val();

2. 부모창에 값 전달하기

opner.document.getElementById( "p_id" ).value = "c_value";

$( "#hidValue", opener.document ).value( "c_value" );

3. 부모창 함수 호출

opener.location.href = "javascript:p_fun();";

$( opener.location ).attr( "href" , "javascript:p_fun();");

 

 

출처 - http://freesemo.blog.me/100155523015

반응형
반응형

후우... params 로 값 넘겨서 작업 페이지에서 받은뒤에 처리함.. 그리고 화면에 뿌린 데이터를 가져와서 그걸로 처리...

ps. 일하면서.. 만들었다... 슬프다..ㅠㅠ

반응형
반응형

 

 

일정 시간마다 동일한 함수를 실행하는 함수.

그리고 그 함수를 멈추는 함수.

자동실행 되게 셋팅하고

마우스 포커스 온 되면 멈추고 포커스 아웃되면 재실행 시키는 방식으로 활용

반응형
반응형

<script type="text/javascript">
function resizeHeight(id)
{
    var the_height = document.getElementById(id).contentWindow.document.body.scrollHeight;
    document.getElementById(id).height = the_height + 30;
}
</script>
<iframe src="#" id="commentFrame"frameborder="0" onLoad="resizeHeight('commentFrame');"></iframe>


출처 - http://eyecandyzero.tistory.com/173

반응형
반응형

function date_chk(year, month, day){
 date1 = new Date(year, month-1, day);
    year_chk = date1.getYear();
    month_chk = date1.getMonth();
    day_chk = date1.getDate();
 if( year == year_chk && month-1 == month_chk && day == day_chk ){
  alert("날짜 정상");
 }else{
  alert("날짜가 비정상");
 }
}

자바 스크립트에서 받아오는 날짜는 월이 0~11 로 계산됩니다.
그리고 자동으로 가감을 하여 날짜를 받아오기때문에 정상적인 날자를 받아오게 되고
이 받아온 날짜를 입력한 날짜와 대조하여 날짜가 서로 동일하면 유효한 날짜인거고
동일 하지 않으면 유효하지 않은 날짜인것입니다.
반응형
반응형


스크립트 소스

<script language="javascript" type="text/javascript">//체크박스 전체 선택용 스크립트
function checkAll(idx){
  var all_check = document.getElementsByName("i_t_idx");
  for(var i=0;i<all_check.length;i++){
   if(all_check[i].type == "checkbox")
   {
    all_check[i].checked = idx;
   }
  }
 }
</script>

체크박스 소스
<input type="checkbox" onclick="checkAll(this.checked)"/>



출처 - 수호천사의 블로그 (http://blog.naver.com/cobin?Redirect=Log&logNo=140133643136)
반응형

'공부거리 > JAVASCRIPT' 카테고리의 다른 글

숫자 체크  (0) 2012.04.09
날짜 유효성 검사  (0) 2012.03.07
스크립트 정규식 소스 조금  (0) 2012.01.10
[스크립트]window.open() 스크립트 옵션 및 예제  (0) 2011.12.15
[SCRIPT] 라디오 버튼 자동 선택  (0) 2011.12.12
반응형

window.open()

함수 설명: MS IE 팝업창 띄우는 스크립트

함수 형식: window.open("url","window name","option");

 

옵션:

menubar=yes/no

toolbar=yes/no

location=yes/no  주소창

scrollbars=yes/no

fullscreen

width

height

top

left ..

 

사용법: 아래예제는 창이 열리면서 팝업을 띄우고 부모창은 사라지는 것임.

주의: 팝업창 열리는 것이 막혀있으면 팝업 뜨기전에 부모창이 닫히므로 창을 구경할 수 없게 된다.. 일정 시간 이후 띄우거나 해야함..

 

<script type="text/JavaScript">
<!-- 
 window.open("welcome.jsp","show","width=303,height=212,toolbar=no,menubar=no");
 setTimeout(function(){top.window.opener = top;top.window.open('','_parent','');top.window.close();}); // <--부모창 자동 닫기
//-->
</script>



출처 - 내 작은공간(http://ilinkyou.blog.me/30106501260)

반응형

'공부거리 > JAVASCRIPT' 카테고리의 다른 글

숫자 체크  (0) 2012.04.09
날짜 유효성 검사  (0) 2012.03.07
스크립트 정규식 소스 조금  (0) 2012.01.10
[스크립트]체크박스 전체 선택/해제  (0) 2011.12.20
[SCRIPT] 라디오 버튼 자동 선택  (0) 2011.12.12
반응형

데이터베이스로 부터 받은 입력값을 라디오버튼으로 설정해야 할 경우가 있다.
셀렉트 박스일 경우에는 폼의 value 값으로 쉽게 설정이 가능하지만 라디오 버튼의 경우에는 name이 같기 때문에 name.value = "값" 으로 설정을 할수가 없다.
라디오 버튼의 경우에는 배열로 해결할수가 있다.

<html>

<head>

<script>

onload = function() {                                            // 페이지가 로드되면 자동으로 실행

              var frm = document.form(0);                    // 처음 폼을 frm으로 정의

              var gender = “<%데이터베이스로 부터 받은 값%>”;

if( gender == “m” ) {

frm.gender(0).checked = true;          // 배열로 표시가능

} else {

          frm.gender(1).checked = true;

}

}

</script>

</head>

<body>

<form>

<input type=”radio” name=”gender” value=”m” />

<input type=”radio” name=”gender” value=”f” />

</form>

</body>

</html>


만약 데이터베이스로 부터 받은 값이
m 일 경우에는 남에 체크가 된다.

라디오 버튼이 하나일경우에는 다중 라디오 자동선택으로는 선택이 정상적으로 되지 않는다.



출처 = http://theqoop.tistory.com/93
반응형
반응형
 <script language="javascript">
  function openPopup5()
  {
   window.open('/print/print06.asp','SmallWindow','width=800,height=600,toolbar=no,scrollbars=yes,left=0,top=0');
  }
 </SCRIPT>

반응형

'공부거리 > HTML' 카테고리의 다른 글

웹표준, 웹접근성 검사 사이트  (0) 2012.01.25
input 박스 숫자만 입력받기  (0) 2011.12.23
스크립트로 추정되는 정규식(?)  (0) 2011.11.10
[JavaScript] 알아두면 좋은 함수  (0) 2011.11.10
html 태그 정리  (0) 2011.11.07
반응형

 

Test()

문자열 사이에 영어가 있는지?(A ~ z)
  1. var username = 'JohnSmith';
  2. console.log(/[A-Za-z_-]+/.test(username)); //return true
  3. username = '한국인';
  4. console.log(/[A-Za-z_-]+/.test(username)); //return false
  5. username = '**A*';
  6. console.log(/[A-Za-z_-]+/.test(username)); //return true

Split()

문자를 띄워쓰기 기준으로 잘라 배열로 반환
  1. var str = 'this is my string';
  2. console.log(str.split(/\s/)); //logs : [this, is, my, string]
  3.  
  4. str = '이건 내가 작성한 문자열';
  5. var str2 = str.split(/\s/);
  6. console.log(str2[1]); //logs : 내가
  7. console.log(str2[3]); //logs : 문자열

Replace()

치환 정규식
  1. //ex1)
  2. var someString = 'Hello, World';
  3. someString = someString.replace(/World/, 'MyBlog');
  4. console.log(someString); //return Hello, MyBlog
  5. //ex2)
  6. var username = 'J!o!h!n!Smith!!~';
  7. username = username.replace(/[^A-Za-z\d_-]+/,'');
  8. //처음나오는 특수문자 제거
  9. console.log(username); // logs : Jo!h!n!Smith!!~
  10. //ex3)
  11. var username = 'J!o!h한n !Sm글ith!!~';
  12. username = username.replace(/[^A-Za-z\d_-]+/g,'');
  13. //문자열사이 특수문자(띄어쓰기포함) 전부제거
  14. console.log(username); // logs : JognSmith

Match()

매치되는 특정 문자 or 문자열 반환
  1. var name = 'UYEONG';
  2. console.log(name.match(/U/)); // logs "U"
  3. var str = "너는착한놈이야";
  4. console.log(str.match(/착한놈/)) // logs "착한놈"
  5.  
  6. var name = 'axaxaxsvsvsv';
  7. //검사하여 해당문자 배열로반환
  8. console.log(name.match(/a/g)) // logs ["a","a","a"]
  9.  
  10. var string = 'this is just a string with some 12345 and some !#$@# meixed in.!';
  11. console.log(string.match(/[a-z]+/gi));
  12. // logs : ["this", "is", "just", "a", "string", "with", "some", "and", "some", "meixed", "in"]
  13. console.log(string.match(/[a-z]+/gi)[1]); // logs : is

emailAdress :

이메일을 검사한후 문자열로 반환
  1. var email = 'uyeong21c@gmail.com';
  2. console.log(email.replace(/([a-z\d_-]+)@([a-z\d_-]+)\.[a-z]{2,4}/ig, '$1, $2'));
  3. // logs : uyeong21c, gamil

url :

url을 구조기준으로 잘라 반환
  1. function loc(url) {
  2. return {
  3. search : function() {
  4. return url.match(/\?(.+)/i)[1];
  5. },
  6. hash : function() {
  7. return url.match(/#(.+)/i)[1];
  8. },
  9. protocol : function() {
  10. return url.match(/(ht|f)tps?:/)[0];
  11. },
  12. href : function() {
  13. return url.match(/(.+\.[a-z]{2,4})/ig);
  14. }
  15. }
  16. }
  17. var l = loc('http://www.somesite.com?somekey=somevalue&anotherkey=anothervalue#theHashGoesHere');
  18. console.log(l);
  19. console.log(l.search());
  20. console.log(l.hash());
  21. console.log(l.protocol());
  22. console.log(l.href());





출처 - UYEONG's Blog(http://uyeong.tistory.com/189)

반응형

'공부거리 > HTML' 카테고리의 다른 글

input 박스 숫자만 입력받기  (0) 2011.12.23
[Script]팝업 띄우기  (0) 2011.12.08
스크립트로 추정되는 정규식(?)  (0) 2011.11.10
html 태그 정리  (0) 2011.11.07
기본적인 HTML 문  (0) 2011.10.26

+ Recent posts