imported>Bbon
imported>Bbon
1번째 줄: 1번째 줄:
 
== 자주 사용하는 함수 구현 ==
 
== 자주 사용하는 함수 구현 ==
=== trim 구현 ===
+
=== trim() 구현 ===
 
<syntaxhighlight lang="javascript">String.prototype.trim = function () {
 
<syntaxhighlight lang="javascript">String.prototype.trim = function () {
 
     return this.replace(/(^\s*)|(\s*$)/g, '');
 
     return this.replace(/(^\s*)|(\s*$)/g, '');
 
}</syntaxhighlight>
 
}</syntaxhighlight>
 +
===replaceAll() 구현===
 +
<syntaxhighlight lang="javascript">String.prototype.replaceAll = function(target, replacement) {
 +
  return this.split(target).join(replacement);
 +
};</syntaxhighlight>
 
===Window.opne() ===
 
===Window.opne() ===
 
팝업을 열고, 팝업창이 닫힐때 부모창 리로드
 
팝업을 열고, 팝업창이 닫힐때 부모창 리로드

2014년 1월 16일 (목) 09:40 판

자주 사용하는 함수 구현

trim() 구현

String.prototype.trim = function () {
    return this.replace(/(^\s*)|(\s*$)/g, '');
}

replaceAll() 구현

String.prototype.replaceAll = function(target, replacement) {
  return this.split(target).join(replacement);
};

Window.opne()

팝업을 열고, 팝업창이 닫힐때 부모창 리로드

$(window).on('beforeunload', function () {
                opener.location.replace(opener.location.href);
            });