• Google Buzz

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 :

With Entities Encoded: (Click to Select All)
Want this code? If you just copy/paste code below to webpage it should work. Javascript code with script tags to put in html code/webpage

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 += {'<':'&#60;', '>':'&#62;', '&':'&#38;', '\"':'&#34;', '\'':'&#39;', '-':'&#45;', '/':'&#47;', '=':'&#61;', '!':'&#33;', '(':'&#40;', ')':'&#41;', '[':'&#91;', ']':'&#93;', '{':'&#123;', '}':'&#125;', '\n':'&#13;'}[c] || c;
  }
  return result;
}
function do_encode(e){
  $('pre').innerHTML = $('dst').value = encode_entities(e.value)
}
 
//]]> 
 
</script>
Make sure to put htmlencoder_nojstags.js file on your server and don’t just copy paste the below code unless you add: <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>
Courtesy of Dan Kogai’s HTML Encoder with a little bit of modification.


~~~~~Written by Tom -Visit Website~~~~~
~~~~~Subscribe to my RSS Feed.~~~~~

VN:F [1.8.4_1055]
Rating: 9.0/10 (2 votes cast)
VN:F [1.8.4_1055]
Rating: 0 (from 0 votes)
HTML Encoder 9.0102

Popularity: 1%



Related Posts
Related Websites