Javascript에서 VB의 replace(str,a,b) 같은 함수를 쓰기위함입니다.

vb
str = replace(str,a,b)

javascript

str = str.replaceAll(a,b);

- include this function

String.prototype.replaceAll = function(str1, str2){

  var temp_str = "";
  var temp_trim = this.replace(/(^\s*)|(\s*$)/g, "");

  if (temp_trim && str1 != str2)
  {
    temp_str = temp_trim;
    while (temp_str.indexOf(str1) > -1) temp_str = temp_str.replace(str1, str2);
  }

  return temp_str;
}

'My Job > Script' 카테고리의 다른 글

jQuery 로 Ajax 개발을 단순화하기..  (0) 2009/04/24
Jquery 플러그인 모음  (0) 2009/04/03
[javascript] prototype replaceAll Function  (0) 2008/07/15
JavaScript Framework  (0) 2008/03/07
스크립트로 마우스휠 제어하기  (0) 2008/03/05
KeyCode 정리  (0) 2008/03/05
Posted by 두리미



부드러운 함수와 랜덤컬러에 대한 정의를 무비클립 prototype으로 정의해놓고 쓴 샘플입니다.

 

소스코드

Posted by 두리미
이전버튼 1 이전버튼