How to use 'text to html javascript' in JavaScript

Every line of 'text to html javascript' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
159function html2js(text){
160 var split1 = text.split("\n");
161 text = "var text = \"\";\n";
162 for(var i=0;i<split1.length;i++) {
163 var str = split1[i];
164 text += "text += \""+str.replace(/"/g,"\\\"")+"\";\n";
165 }
166 return text;

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

Related snippets