encode html entities javascript - Web Development and Web Design Codes

Latest

Tuesday, February 13, 2018

encode html entities javascript

encode html entities javascript

encode html entities javascript
encode html entities javascript
in This lesson we are going to learn how to encode html entities in JavaScript..
just use the below example to create your own html encoder in JavaScript..

Codes: index.html

<script type="text/javascript">
function HTML(){
var re = /(<)/gi;
var rg = /(>)/gi;
for (i=0; i < arguments.length; i++){
arguments[i].value=arguments[i].value.replace(re, "<")
arguments[i].value=arguments[i].value.replace(rg, ">")
}
}
function clear()
{
document.myform.remove.value='';
}


document.onLoad="clear()";
</script>
<div align='center'>
<form name="myform">
<textarea style="background-color:f0f0f0; border 1px border:1px solid #afc784;" name="remove" rows="15" cols="40"></textarea><br>
<input type="button" value="Encode" onClick="HTML(this.form.remove)">
</form>
</div>
<div class="clear"></div>

That's it guys how to create html encoder in javascript..
Keep visiting this blog for more codes..
Thank You...

No comments:

Post a Comment

Thank You for Your Comment

Note: Only a member of this blog may post a comment.