Skip to content

escapeString

Mike Byrne edited this page Jan 25, 2022 · 4 revisions

description

Strips a string of HTML and returns a URI encoded string of the text content of a string, useful for social sharing links

requires

  • nothing

parameters

  • str - required - string to be stripped

returns

  • URI encoded string

example usage:

<h1>Optical Cortex <a href="http://www.area17.com/">AREA 17</a></h1>
var title = document.getElementsByTagName("h1")[0].innerHTML;
var title_safe = escapeString(title); // "Optical%20Cortex%20AREA%2017"