codice:
<html><head>
<script type="text/javascript">

var original = "L' inverno a L'Aquila";
var added    = original.replace(/'/g, "\\\'");   //simula il server-side addslashes

function setup(){
document.getElementById("fld1").value = original;
document.getElementById("fld2").value = added;
document.getElementById("fld3").value = added.replace(/\\\'/g, "'");
}
window.onload=setup

</script>
</head><body>

<input id="fld1" size="80" style="font-family: monospace;">

<input id="fld2" size="80" style="font-family: monospace;">

<input id="fld3" size="80" style="font-family: monospace;">

</body>
</html>