Forum Moderators: open

Message Too Old, No Replies

IE bug - document.body.innerHTML doesn't include password value?

input type password value is empty

         

Fotiman

10:20 pm on Feb 17, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I have stumbled upon an IE bug that is really causing me problems. If anyone has any idea if there's a workaround, I'd love to hear it.

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>

DrDoc

10:44 pm on Feb 17, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Is that really bad? :)

You can always check the value directly.

Fotiman

10:48 pm on Feb 17, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



But I'm doing this global replace where I don't know the names of the fields or anything... I'm just getting it all, replacing a few small parts of it, and shoving it back to the browser. But IE isn't picking up the value on these password inputs, so the it's removing them all.

Yes, I would say that's bad.

DrDoc

2:53 am on Feb 22, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



That's an interesting problem though. I mean, yes I can understand why IE does what it does (from a security point of view) ... But, for the love of something green -- don't! And, while you're at it, leave my quotes, tag case, etc alone! IE's crappy JavaScript implementation turns really useful and nifty stuff into something completely unusable.