HTML Encoder
Have you ever wanted to encode your html to make it show up inside of um say wordpress post and not be ran through html scripting? Well here yah go: This will output that for you!
(Allthough this will not work in IE) Working on a solution for that (try this)
Source Text :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | <script type="text/javascript">
//<![CDATA[
function $(id){ return document.getElementById(id) }
function encode_entities(s){
var result = '';
for (var i = 0; i < s.length; i++){
var c = s.charAt(i);
result += {'<':'<', '>':'>', '&':'&', '\"':'"', '\'':''', '-':'-', '/':'/', '=':'=', '!':'!', '(':'(', ')':')', '[':'[', ']':']', '{':'{', '}':'}', '\n':' '}[c] || c;
}
return result;
}
function do_encode(e){
$('pre').innerHTML = $('dst').value = encode_entities(e.value)
}
//]]>
</script> |
<script type="text/javascript"></script> tags. You also have to add the forms portion of the code too.
note: Javascript code without script tags are to put in *.js file
Forms file/html
1 2 3 4 5 6 | Source Text : <div id="form"> <textarea cols="80" rows="16" onkeyup="do_encode(this)" onchange="do_encode(this)"></textarea> With Entities Encoded: (Click to Select All) <textarea id="dst" cols="80" rows="16" onfocus="this.select()" onclick="this.select()"></textarea> </div> |
Popularity: 1%
Related Posts
- Top 15 wordpress 2.7.1 plugins There is a lot of "stuff" on my page and...
- FATAL ERROR MEMORY ISSUES Wordpress Ok So I needed to install a new version of...
- My own RSS for music files from PHP If you have read the previous post about the Website...
- Add Image Icons With Text Ok When I was developing my plugin I found some...
- Changing a text box’s AutoFit behavior When there is too much text to fit in a...
- Increasing Your Search Engine Ranking The methods employed to increase your search engine rankings may...
- More traffics with Digg Button on your blog This is a step-by-step guide to automatically place a real-time...
- Assigning appointments to categories As with most Outlook items, an appointment can be assigned...

Firefox