Quantcast
Viewing latest article 10
Browse Latest Browse All 25

Adding HTML from a string the safe way

Adding HTML from a string isn’t difficult. Something like this works amazingly: name="John" html = `<div>Hello <b>${name}</b>, <p>Welcome on this lovely day</p> </div>` document.body.innerHTML=html; It’s easy and it’s fast, but it is not safe! Copy and paste above code in your browser console and execute it. It will remove all content, and show the new […]

Viewing latest article 10
Browse Latest Browse All 25

Trending Articles