Forum Moderators: open
The example page below demonstrates the problem. I have a script that replaces all <abbr> elements with <acronym> elements. It does so by getting document.body.innerHTML, and doing a string replace. However, when it gets document.body.innerHTML, the "value" of all password fields is empty, while other form input values are included just fine. Thus, when it does the replace, all of the password fields end up empty.
Any ideas?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset:utf-8">
<title></title>
<script type="text/javascript">
window.onload = function()
{
var oldBodyText, newBodyText, reg;
oldBodyText = document.body.innerHTML;
alert(oldBodyText);
reg = /<ABBR([^>]*)>([^<]*)<\/ABBR>/g;
newBodyText = oldBodyText.replace(reg, '<acronym $1>$2</acronym>');
alert(newBodyText);
document.body.innerHTML = newBodyText;
}
</script>
</head>
<body>
<div id="container">
<form action="">
<div>
<input type="text" name="ab" id="abc" value="222">
<input type="password" name="vm" id="vmp" value="111">
</div>
</form>
</div>
</body>
</html>
Yes, I would say that's bad.