| Site Map | WizTools.org | jCraze Blog |
![]()
|
JavaScript HTMLize (Using Regular Expressions)Often we are faced with the task of converting HTML special characters. I always used to write this functionality in the server side. But having this functionality in the client side would save server's processing time. Also some functionality like a preview of text entered could be efficiently achieved by client side scripting. Now, the characters to be changed:
The JavaScript function to convert the same:
<script language="javascript">
function htmlize(str){
str = str.replace(/\&/g,"&");
str = str.replace(/\</g,"<");
str = str.replace(/\>/g,">");
str = str.replace(/\"/g,""");
str = str.replace(/\n/g,"<br/>\n");
return str;
}
</script>
Now would you like to check this functionality? Add some special characters, and click on the `HTMLize' button: |
[Quick Stats: Number of main threads: 3, Number of sub-threads: 1]
Sign Guestbook
|
Who is Subhash?
The contents of this site are copyright© 2000-2008, indiWiz.com. All Rights Reserved.