Who is changing my DOM?

What can change the DOM of a web page after the browser receives a response?

I see this behavior in the value of a hidden input element that contains a one-off form token.

When I view the source code in a browser, I see the correct value specified on the server. When I submit a form, view the current DOM state, or simply change the element to text input, I see a different line. Thus, the value that the input enters when it is sent back to the server is different from the value that was sent by the server.

The problem persists when javascript is disabled. Adding a readonly attribute to the element didn't help either.

NEW INFORMATION: I've played around a bit with this, and believe it or not, converting images to Firefox makes this problem out of the question.

Why would this happen?

+1


source to share


4 answers


I was wrong in my interpretation of what was happening. I think it's a good thing because what I thought I was seeing should never happen! Anyway, here's the situation, as I understand it now:

The form symbol is one-time use here, so it is only valid for one page load. Somewhere else on the page, there was an img tag without a src attribute, which made the browser try to load an image from /. Since the index page is a php page, the token is called circularly.



I figured the DOM had changed, I think, because some "view source" implementations (I tested in multiple browsers) seemed to cause the page to reload as well ...

Thanks for all the suggestions.

+1


source


If the browser has the ability to "save form data", it can pre-fill the data with a previously submitted value.



(I would expect popular browsers to be smart enough not to fill in hidden fields, but I can suggest one ...)

+1


source


You may be able to insert the readonly = "readonly" tag and autocomplete = "off" .

Not sure if browser autocomplete will do this, but it's plausible, you can also try disabling autocomplete in your testing browsers and see if that changes anything.

+1


source


What do you mean by "when I submit the form, I'm looking at the current DOM state"?

If you submit a form, does it send a request to the server? Are you talking about the state of the DOM on the resulting page sent by the server?

It's not entirely possible that in the absence of client-side scripting, your DOM will be modified on the client-side.

If, on the other hand, you submit to the server and return a completely new DOM, then, well, the server has changed it.

0


source







All Articles