2013-08-14 3 views
0

저는이 프로토 타입을 시험하고 있습니다. 프로토 타입 안에 더 많은 것들을 추가 할 것입니다. 내가 잘못하고있는 것은 무엇입니까?프로토 타입 및 substr

말했다되고 그건
String.prototype.replaceme = function() { 
    return this.replace("&lt;", "<").replace("&gt;", ">"); 
} 

, decode HTML entities 아마 더 좋은 방법이 있습니다 :

String.prototype.replaceme = function(){ 
    var toreplace; 
    toreplace = this.substr("&lt;","<") 
    toreplace += this.substr("&gt;",">"); 
    return toreplace; 
} 
+0

무엇을하려고합니까? – bfavaretto

답변

1

그럼 당신이 대체를 수행하기 위해 노력하고있다, 그래서 당신은 substr() 대신 replace()를 사용해야 것 같습니다.

+0

고맙습니다.이 작품은 너무 좋아요. :) 고맙습니다 !! 리턴이 \t \t .replace ("<", "<스팬 스타일 ="색상 : #의 C0C0C0; '> « "이것은) \t :) 제가 필요로 –

+0

편집이 난에 대해보고하는 용액은 \t .replace (">", "»"); –