Well i have var message, which has any type of character…
I replace 🙂 with <img src="..." .../> and http://www.youtube.com/watch?v=id with <a href="...">...</a>
Then I run $(".chat_message").html(message);
What must I do to embed anything excepts the html tags I make as html code to screen??
I’m going to assume you want each character in
messageexcept the ones you replace with HTML tags to show literally on the screen.will put the HTML equivalent of
messageinmessageHTML*.Once
messageHTMLcontains a string of HTML, you can replace all occurrences of":)"safely and correctly since that is just a simple HTML -> HTML conversion.Now you can use jQuery’s
.html(messageHTML)to injectmessagewith your tags into the DOM.* – the white-space will differ unless you’re embedding in a context with CSS
white-space: preorwhite-space: pre-wrap