Forum Moderators: open

Message Too Old, No Replies

"Save Page As" alters page source

Neither FF2 nor IE6 saves verbatim

         

cameraman

12:07 am on Apr 21, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I have a page on my website that I encourage visitors to save to their own hard drives. I made some changes to it today. One of the changes I made was to switch it from transitional to strict. The page has some text inputs on it, so I added the closing slashes to them. Then I saved the page to my desktop (from my website) to make sure everything was working the way I wanted.

I was surprised to discover that when saved from FF2, FF removed the closing slashes before saving the file!

So I opened up IE6 and saved the file from it. It removed the slashes, capitalized all of the element names, and changed the doctype to transitional. It also used the page title with an extension htm for a filename instead of the document's filename with its html extension.

WHAT the heck is up with all that?!?

encyclo

12:14 am on Apr 21, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Are you talking about XHTML 1.0 Strict (where the trailing slashes are required to validate) or HTML 4.01 Strict?

Bear in mind that, whichever syntax you have chosen, than technically-speaking the trailing slashes are treated as coding errors by the browser when serving the file as

text/html
. Firefox in particular does some error-correction when saving the parsed file, so you are possibly seeing the result of the corrected source code.

<added> Testing a simple XHTML page in Firefox, I can see that the saved file represents the page after parsing and error-correction - the slashes are dropped as the file is treated as HTML. I assume IE works in a similar way.

This is "normal" behavior in that the trailing slash usage in XHTML-as-

text/html
is dependent on such error-handling by the browser. XHTML-as-
text/html
is actually nothing more than slightly-broken HTML, and this test is a good demonstration of that fact. ;) </added>

cameraman

2:23 am on Apr 21, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



WOW I just got a major education.

Are you talking about XHTML 1.0 Strict (where the trailing slashes are required to validate) or HTML 4.01 Strict?

Seemingly simple question - I didn't know there was a difference.

I did a search here, starting with this recent thread [webmasterworld.com] by SuzyUK (which I have to confess I had apparently skimmed too quickly when she posted it), and moving on to your (encyclo's) thread [webmasterworld.com] on the subject and finishing up with DrDoc's thread [webmasterworld.com], both from last August. I read the whole first page but my brain hurts now so I guess the other pages will have to wait for another day.

Apparently my error has been that my eyes unfocus once I see either 'transitional' or 'strict' in the doctype. I thought all this time that I was doing good, any new pages are written to 'strict' and as I modify older pages I change them to strict. I thought I wanted XHTML, but after all that reading it's abundantly clear that I want HTML 4.01 strict. Sigh, I have a lot of trailing backslashes to remove...

Thanks encyclo, both for today and your input in the other threads.

rocknbil

5:54 pm on Apr 21, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Feelin' for ya' man! I am constantly annoyed by code I have to rework because of those. Most of the documents I have to clean up don't even *have* a doctype!

Do you have a powerful editor like HomeSite? It can rip through thousands of files in a few short seconds, even traversing subdirectories, on a global search and replace, without ever manually opening one file.

cameraman

8:28 pm on Apr 21, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Humph, I thought I did but apparently not - I can do global searches, but not global replaces.
That's a good idea though, I could write a script to do it - couldn't be much more than 10-15 lines.

Oh and after I 'fixed' that one file (and did a validity check), FF started saving it ok but IE6 still changes it; sets it to transitional loose and capitalizes all the elements.