js本身没有提供该方法,但是用个正则可以做到。下面是将文本域里面的半角双引号全部替换成全角双引号。
<html>
<head>
<title></title>
<script language="javascript">
function replaceAll()
{
var str = document.all('book').value;
var newValue = str.replace(new RegExp("/"","gm"),"“");
document.all('book').value = newValue;
}
</script>
</head>
<body>
<form>
<input type="button" value="替换" οnclick="replaceAll();"/>
<textarea cols="50" rows="10" id="book" name="book">
</textarea>
</form>
</body>
</html>