ccc

Javascript: strip_tag, quitar código HTML

// borra todo el codigo html
        function stripHTMLTags(text) {
            var inicio = text.indexOf("<", 0);
            var fin=0;
            if (inicio == -1)
                return text;
            else {
                fin = text.indexOf(">",inicio);
                if (fin == -1)
                    return text
                else
                    return ( stripHTMLTags(text.substring(0,inicio) + text.substring(fin+1) ) ) ;
            }
        }
       
        // borra todos los &nbsp;
        function borraNBSP(text) {
            var pos = text.indexOf("&nbsp;");
            if (pos == -1)
                return text;
            else return  borraNBSP(text.substring(0,pos) + text.substring(pos+6));
        }

No hay comentarios:

Publicar un comentario