<!-- Add JS Before build -->
<script src="JS/jquery-1.6.2.min.js" type="text/javascript"></script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<script type="text/javascript" >
function validateTxt() {
var div = document.getElementById("Div1");
var str = "<h1> Hello.. </h1><br /> <b><i> Chirag Here :) </i></b>";
str = this.replaceAll(str, "&", "&");
str = this.replaceAll(str, "<", "<");
str = this.replaceAll(str, ">", ">");
str = this.replaceAll(str, " ", " ");
var str4Div = str;
div.innerHTML = str4Div;
}
function replaceAll(str, subStr, newStr) {
var offset = 0;
var index = str.indexOf(subStr);
while (index != -1) {
offset = index + newStr.length;
index = str.indexOf(subStr, offset);
}
return str;
}
$(document).ready(function() {
validateTxt();
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div id="Div1" onload="javascript:validateTxt();" >
</div>
</form>
</body>
</html>
OutPut::
0 comments:
Post a Comment