Safari innerHTML not getting form values

K

KK

Please help!

I am currently experiencing a bug in Safari v125.9.
When I modify the value of form input box and then get the innerHTML
property of the surrounding div object - I am returned the original
form value not the changed value!

Has anyone else encountered this?

Cheers.
 
R

Randy Webb

KK said:
Please help!

I am currently experiencing a bug in Safari v125.9.
When I modify the value of form input box and then get the innerHTML
property of the surrounding div object - I am returned the original
form value not the changed value!

Thats correct behavior. You are changing the form elements value, not
the innerHTML of the form element itself.
 
J

Jim Ley

Thats correct behavior. You are changing the form elements value, not
the innerHTML of the form element itself.

Well there's no specification for innerHTML other than at best the
behaviour of IE, but I would say it should be the serialisation of the
current DOM, in which case it should return the current, not the
original value.

Jim.
 
R

Randy Webb

Jim said:
Well there's no specification for innerHTML other than at best the
behaviour of IE, but I would say it should be the serialisation of the
current DOM, in which case it should return the current, not the
original value.

I should have tested this in IE first, but IE seems to be the only one
that actually gives the serialized HTML code.

<div id="myDiv">
<form name="myForm">
<input type="text" value="original value" name="myInput">
<input type="button"
onclick="document.myForm.myInput.value='new value';"
value="Change the Value">
<input type="button"
onclick="alert(document.getElementById('myDiv').innerHTML)"
value="Show the HTML">
</form>
</div>

For simplicity sake, I am only posting the relevant parts of the
innerHTML properties.

IE6 SP2 XP:
Alert prior to changing: value="original value";
Alert after changing: value="new value";

Opera 7.54:
Alert prior to changing: value="original value";
Alert after changing: value="original value";

Mozilla 1.7.1:
Alert prior to changing: value="original value";
Alert after changing: value="original value";

Netscape 7.2:
Alert prior to changing: value="original value";
Alert after changing: value="original value";
 
R

RobG

KK said:
Please help!

I am currently experiencing a bug in Safari v125.9.
When I modify the value of form input box and then get the innerHTML
property of the surrounding div object - I am returned the original
form value not the changed value!

Has anyone else encountered this?

Cheers.

For the record, both Firefox and Netscape have the same behaviour; only
IE seems to update the innerHTML. Given that, in this case, IE is the
"standard", then they all share the same "bug".

I think Jim has the right idea, if for no other reason than if IE is
the standard, then the others should at least do what IE does.

Of course there are work arounds, post again if you have a specific
issue.

Have a good one.
 
R

Randy Webb

RobG said:
For the record, both Firefox and Netscape have the same behaviour; only
IE seems to update the innerHTML. Given that, in this case, IE is the
"standard", then they all share the same "bug".

IE is not the "standard". Far from it.
I think Jim has the right idea, if for no other reason than if IE is
the standard, then the others should at least do what IE does.

Thats a dangerous statement to make. IE does this:

idOfElement.innerHTML;

but no other browser does. Does that mean they all have a bug? No.
 
M

Michael Winter

[snip]
Well there's no specification for innerHTML other than at best the
behaviour of IE, but I would say it should be the serialisation of the
current DOM, in which case it should return the current, not the
original value.

However, the value attribute represents the initial (default) value of
that form control. That attribute doesn't change if the user modifies the
text themselves, does it.

I would expect the innerHTML text to change if the defaultValue property
was altered, and indeed that is the case with Opera, Mozilla and Firefox.

Mike
 
R

RobG

Randy Webb wrote:
[...]
IE is not the "standard". Far from it.

If the others are attempting to emulate it, then, in this case, it is.
I was in no way suggesting that IE is *the* standard - heaven forbid!!
Thats a dangerous statement to make. IE does this:

idOfElement.innerHTML;

but no other browser does. Does that mean they all have a bug? No.

No, but the non-standard behaviour of IE is not the topic of the
thread. It's whether other browsers are correctly emulating IE or not.

I guess it's an issue when reverse engineer something - do you
slavishly copy the behaviour, or modify it to create a "better"
version? Either way, you are going to annoy someone - the current
issue being a case in point.

It is moot whether it is more correct for innerHTML to reflect the
actual script, the user-modified script, the programmatically modified
script or even the browser-parsed-and-rendered script. Excellent
arguments are presented above for various cases.

Microsoft does not specify what innerHTML should do in that regard, it
seems to be intended to replace the content of a tag pair, not to read
what is currently there, though that seems to be a common use for it.
So whoever wishes to emulate innerHTML only has IE's behaviour to copy
from, and it returns the user modified value of input elements, not the
original scripted value (unless it hasn't been modified).


<URL:http://msdn.microsoft.com/workshop/author/dhtml/reference/properties/innerhtml.asp>

"When the innerHTML property is set, the given string completely
replaces the existing content of the object."

There is no statement on what innerHTML should return when "got", it
just says it is accessible.

So whoever wishes to emulate innerHTML only has IE's behaviour to copy
from, and it returns the user modified value of input elements, not the
original scripted value (unless it hasn't been modified).

None of the above should be interpreted as my endorsement of IE as an
official standard; but just one of many facets of this discussion.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top