Answer by Rick Hitchcock for convert HTML code to Javascript variable (string)
This will take the input from a textarea and create the variable code. It escapes backslashes and quotes as needed: function makeVariable() { var code= document.getElementById('input').value.trim(),...
View ArticleAnswer by Richard Peck for convert HTML code to Javascript variable (string)
If I'm right in assuming you want to generate "encoded" HTML through JS, this resource seems to answer the question: function OuterHTML(element) { var container = document.createElement("div");...
View ArticleAnswer by Nishanth for convert HTML code to Javascript variable (string)
Method 1 Remove the line breaks, making the entire string a single line var lines = '<div id="jwplayer"><center>...</center></div>'; document.write(lines); Method 2 Escape the...
View Articleconvert HTML code to Javascript variable (string)
Actually I have a strange requirement. Here I have HTML code and I have to pass this code into document.write function. To achieve that I should make that code into javascript variable and pass that...
View Article