How to Display Code Snippets
Wednesday, May 07, 2008 |
Edit Post
Valid HTML must be encoded into HTML entities before it can appear in its literal format on a web page. Here is a function written in JavaScript to encode HTML for displaying on a web page or blog. The function converts valid HTML into HTML entities:
Try it here:
Raw Output Preview
Try it here:
Paste HTML Source:
Output with Encoded HTML Entities
" gets encoded into " > gets encoded into > < gets encoded into <
To place HTML or JavaScript code anywhere in a document, it's best to encode into html entities.
Dynamic Page QR Code
Popular Posts
-
Product Manager Cover Letter: This real cover letter worked successfully at getting an interview as a product manager. Use it as a templat...
-
Creating randomized valid file paths is a common requirement for many applications such as the case of short url redirects. The Goo.gl url s...
-
If you're interested in placing QR tags dynamically on your site, here's how I did it in less than 5 minutes thanks to Google's ...
-
Cover Letter Examples that I have used successfully to get a job interview: Further to my last post on this topic, there's no substi...
-
Is there a scientific reason that can explain Why People are So stupid? It's not surprising that so many people take advantage of being...
-
Sample for Cover Letters Writing an effective cover letter is essential to get yourself noticed. Use your cover letter as a sample of your...
-
Decoded HTML Encoded HTML Entities /** * Encode HTML tags as HTML Entities * using jQuery * * Code takes raw...
-
In my opinion, Git is a programmers program. It is fast, feature-rich yet intuitive, kind of like Google...there's a new treasure waitin...
-
Blogger RSS URL s can be customized to syndicate content in a user friendly way. This is especially important if you operate a multi-issue b...
-
The example below uses Google's OpenID API to request and validate the user's GMail address. The visitor is first directed to Google...