IE page source differs from Chrome page source...

Ichinisan

Lifer
Oct 9, 2002
28,298
1,236
136
I have a PHP submission form that seems to work fine in both IE and Chrome. When viewing page source in Chrome, I noticed that a <script> tag was never closed:

Chrome:
Code:
<script type='text/javascript'>document.getElementById("submitted").value="yes";

IE:
Code:
<script type='text/javascript'>document.getElementById("submitted").value="yes";</script>

From my PHP source, this is the statement that generates that bit of HTML:
Code:
echo '<script type=\'text/javascript\'>document.getElementById("submitted").value="yes";</script>';

I'm new to PHP and I'm not very familiar with the syntax. I understand that \' should output a single-quote, and a "." combines literal strings and string variables.

"submitted" is a hidden input element, only there to detect if the page was loading for the first time, or if the user already clicked "Submit" without completing all the required fields.

Is there some better way to do that statement?

Thanks!

...now that I think about it, PHP is pre-processed. Why would the server send different HTML to IE versus Chrome? My code has no manual browser detection.

[edit]
I used telnet to request the page without using any browser. The server definitely returns valid code with the closing tag. Why does Google Chrome omit this from the page source?!
 
Last edited:

Ichinisan

Lifer
Oct 9, 2002
28,298
1,236
136
OK, I've simplified it to pure HTML (no PHP) and confirmed that there's a problem with Chrome's View Source option (even when displaying a local HTML file).

Code:
<html>
<input id='submitted'>
<script type='text/javascript'>document.getElementById("submitted").value="Hello, World!";</script>
</html>

Chrome is missing the closing </script> tag when I use the "View Page Source" option. IE shows the closing tag in the source.
 

Sgraffite

Senior member
Jul 4, 2001
209
149
116
Does the source show the closing script tag if you close your input tag and give it a type like so?
Code:
<input type="text" id="submitted" />

I am able to see the closing script tag within my Chrome regardless though.
 

Ichinisan

Lifer
Oct 9, 2002
28,298
1,236
136
I'll have to try that when I get back to work.

I'm using Chrome at home and, just like you, I see the tag with the example HTML.
 

Ichinisan

Lifer
Oct 9, 2002
28,298
1,236
136
Tested with the /> in the Input element. Made no difference.

I'm using Chrome 16.0.891.0 dev-m, so I guess I should report this to the devs before the bug makes it into a regular release.
 

TechBoyJK

Lifer
Oct 17, 2002
16,699
60
91
After having experienced some of the differences between older IE's and the new IE9, I'd have to suggest letting us know which version you are using. IE9 is a headache so far.
 

Sgraffite

Senior member
Jul 4, 2001
209
149
116
I'm using Chrome 16.0.891.0 dev-m, so I guess I should report this to the devs before the bug makes it into a regular release.

I would consider that an important piece of information that should have been mentioned in the first post :(