Answers for "remove script tag in js"

1

remove the html tags in javascript

let strippedString = originalString.replace(/(<([^>]+)>)/gi, "");
Posted by: Guest on October-08-2020
0

remove script tags from html nodejs

# Remove script tags from html nodejs

function stripScripts(s) {
    var div = document.createElement('div');
    div.innerHTML = s;
    var scripts = div.getElementsByTagName('script');
    var i = scripts.length;
    while (i--) {
      scripts[i].parentNode.removeChild(scripts[i]);
    }
    return div.innerHTML;
  }

alert(
 stripScripts('<span><script type="text/javascript">alert(\'foo\');<\/script><\/span>')
);
Posted by: Guest on July-09-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language