3초기억력

HTML TAG 삭제 자바스크립트 본문

코딩_javascript

HTML TAG 삭제 자바스크립트

잠수콩 2016. 8. 22. 10:46
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.



제목 : HTML TAG 삭제 자바스크립트




소스 :


<script type="text/javascript">

<!--

function stripHTML(html)

{

   try {

       var doc = document.implementation.createDocument('http://www.w3.org/1999/xhtml', 'html', null);

       doc.documentElement.innerHTML = html;

       return doc.documentElement.textContent||doc.documentElement.innerText;

   } catch(e) {

       return "";

   }

}

//-->

</script>





내용 :



f.userURL.value = stripHTML(f.userURL.value);


이런 식으로 이용 가능함.






예제 소스 파일 :


 출처 :  http://stackoverflow.com/questions/822452/strip-html-from-text-javascript




Comments