only My site

Wednesday, July 16, 2008

Display HTML without Execute

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">

<title>Example</title>

<script language="JavaScript" type="text/javascript">

<!--

function showTags()

{

str=document.getElementById("txtCode").value;

str=str.replace(/[&]/g,'&amp;');

str=str.replace(/[<]/g,'&lt;');

str=str.replace(/[>]/g,'&gt;');

str=str.replace(/[\n]/g,'<br>');



//document.getElementById('show').innerHTML=str;

document.getElementById('txtCodeop').value = str;

}

//-->

</script>

</head>

<body onload="showTags()">

<div id="show"></div>

<TextArea id="txtCode" name="txtCode"></textArea>

<input type=button id=btnSubmit name=btnSubmit onclick="Javascript:showTags();">

<TextArea id="txtCodeop" name="txtCodeop"></textArea>

</body>

</html>

1 comment:

nalini said...

Its very useful to me thanks for your code