XML prolog before DOCTYPE declaration: trouble for IE6

This forum is for all Flare issues related to the HTML5, WebHelp, WebHelp Plus, and Adobe Air Targets
Post Reply
TheGreatAndPowerfulOz
Sr. Propeller Head
Posts: 131
Joined: Mon Apr 24, 2006 12:52 pm
Location: Glen Mills, PA

XML prolog before DOCTYPE declaration: trouble for IE6

Post by TheGreatAndPowerfulOz »

Hello, all.

I just ran into an interesting situation while testing some Flare WebHelp output in IE6, caused by the XML prolog (<?xml version="1.0" encoding="utf-8"?>) being placed before the DOCTYPE declaration (<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">) in my generated topics.

For any "standard"-type content I have, there is no problem with this, whether rendered in FF or IE. The trouble in IE6 comes, however, with some JavaScript code I'm using in certain topics that depends on the use of "strict" mode as opposed to "quirks" mode. It seems that IE6 will use "quirks" mode if there is anything at all preceding the DOCTYPE delcaration (see http://en.wikipedia.org/wiki/Quirks_mode or http://www.quirksmode.org/css/quirksmode.html for some discussion of the matter), and this causes my JS to fail.

In order to ensure that the script runs alright in other browsers, I'm using Flare's "Add DOCTYPE delcaration to generated topics" option in my WebHelp target, which (unfortunately in the case of IE6) inserts it just *after* the XML prolog, but before the HTML element:

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd">
...
</html>
I can do one of two things in my generated topics to make everything work well in IE6:
  • Remove the XML prolog altogether:

    Code: Select all

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd">
    ...
    </html>
  • ...or move the DOCTYPE declaration *before* the XML prolog:

    Code: Select all

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <?xml version="1.0" encoding="utf-8"?>
    <html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd">
    ...
    </html>
Neither of these solutions have any adverse effect on page rendering in other browsers, but it's a *manual* process, which I hope I will not have to undertake for the (thousands) of topics in my project.

I dread the thought of having to do some sort of crazy find/replace operation on generated output to accomplish this, and I wondered if anyone else here in the forum might have tackled this issue in some other way. Perhaps a modification to some Flare file used in the output generation process? I'm not too familiar with that set of files (don't even know if they're configurable), but really wouldn't want to mess with them anyway, since customizations would be 1) not officially supported by MadCap and 2) overwritten with future Flare application upgrades.

Any takers?

Thanks in advance,
Austin Wright

Flare 2022 r3 (18.2.8431.26678) :: TopNav HTML5 / PDF output
LTinker68
Master Propellus Maximus
Posts: 7247
Joined: Thu Feb 16, 2006 9:38 pm

Re: XML prolog before DOCTYPE declaration: trouble for IE6

Post by LTinker68 »

It might be easier to create a masterpage and insert the doctype declaration before the xml declaration in the masterpage (you'll have to do it manually by opening the topic in the Internal Text Editor). That should result in all of your topics being generated with the doctype before the xml.
Image

Lisa
Eagles may soar, but weasels aren't sucked into jet engines.
Warning! Loose nut behind the keyboard.
RamonS
Senior Propellus Maximus
Posts: 4293
Joined: Thu Feb 02, 2006 9:29 am
Location: The Electric City

Re: XML prolog before DOCTYPE declaration: trouble for IE6

Post by RamonS »

TheGreatAndPowerfulOz wrote:The trouble in IE6 comes, however, with some JavaScript code I'm using in certain topics that depends on the use of "strict" mode as opposed to "quirks" mode. It seems that IE6 will use "quirks" mode if there is anything at all preceding the DOCTYPE delcaration (see http://en.wikipedia.org/wiki/Quirks_mode or http://www.quirksmode.org/css/quirksmode.html for some discussion of the matter), and this causes my JS to fail.
As far as I know IE6 always uses quirks mode. That 'mode' as such was added when IE7 came out to still be able to display broken IE6-only non-standard HTML (most dominantly anything that SharePoint produces). IE8 has even three modes. Although I cannot think why anyone in their right mind would still use the notoriously buggy IE6, but I guess there is a good bunch of people who are prevented from using the newer, less broken IE versions. In any case, as soon as your JS is to be displayed in IE I'd make sure that it copes well with quirks mode.
TheGreatAndPowerfulOz
Sr. Propeller Head
Posts: 131
Joined: Mon Apr 24, 2006 12:52 pm
Location: Glen Mills, PA

Re: XML prolog before DOCTYPE declaration: trouble for IE6

Post by TheGreatAndPowerfulOz »

LTinker68 wrote:It might be easier to create a masterpage and insert the doctype declaration before the xml declaration in the masterpage (you'll have to do it manually by opening the topic in the Internal Text Editor). That should result in all of your topics being generated with the doctype before the xml.
Lisa,

Thanks for the suggestion, but placing the DOCTYPE declaration in my Master Page doesn't seem to have any effect at all on where it might be placed in generated output (it seems to be ignored altogether). When I place it before the XML prolog of the Master Page, then output *without* the "Add DOCTYPE delcaration to generated topics" option selected, no DOCTYPE declaration appears at all in the output. When I do the same, but leave the "Add DOCTYPE delcaration to generated topics" option selected, the declaration still appears after the XML prolog.
Austin Wright

Flare 2022 r3 (18.2.8431.26678) :: TopNav HTML5 / PDF output
TheGreatAndPowerfulOz
Sr. Propeller Head
Posts: 131
Joined: Mon Apr 24, 2006 12:52 pm
Location: Glen Mills, PA

Re: XML prolog before DOCTYPE declaration: trouble for IE6

Post by TheGreatAndPowerfulOz »

RamonS wrote:As far as I know IE6 always uses quirks mode.
Per the articles whose links I posted (and many others I did not) it seems that IE6 *will* respect the DOCTYPE instructions to use strict mode, if there is nothing preceding the declaration.
RamonS wrote:Although I cannot think why anyone in their right mind would still use the notoriously buggy IE6, but I guess there is a good bunch of people who are prevented from using the newer, less broken IE versions. In any case, as soon as your JS is to be displayed in IE I'd make sure that it copes well with quirks mode.
Unfortunately, a large majority of our client base uses IE6, so I'm forced to support it (no real choice in the matter). The JS I'm using is something someone else wrote and I'm not so sure I can figure out how to make it "cope well with quirks mode". The code to which I refer is Shadowbox, used for viewing of various sorts of online media (http://www.shadowbox-js.com/). I can get by alright with some JS coding, but I'm not an expert by any means. Any suggestions along the lines of what to look for?
Austin Wright

Flare 2022 r3 (18.2.8431.26678) :: TopNav HTML5 / PDF output
LTinker68
Master Propellus Maximus
Posts: 7247
Joined: Thu Feb 16, 2006 9:38 pm

Re: XML prolog before DOCTYPE declaration: trouble for IE6

Post by LTinker68 »

Ok, try this. Generate the output. In the output folder, right-click on the default.htm file (or whatever you named the output) and select Open with > Notepad. Add your doctype declaration in the correct spot in the file, then save it. That default.htm file is the frameset for the WebHelp output. I'm hoping that by adding the doctype in that file that it will do what you want without having to figure out a way to get the doctype in every topic, since doing it in the masterpage didn't work.

If you make that modification and it works, then make the same modification to the default_CSH.htm and default_Left.htm files. The _CSH file is used for CSH calls, as is the _Left file, although that's called automatically as part of the _CSH file. I think. Anyway, make the modification in those two files and test them as well (using a CSH call).

If the modifications to those files work, then you can make the change permanent across all projects, if you have the guts (insert evil chuckle here). To do that, go to where Flare was installed and find the default.htm and default_csh.htm files. By default, the files are located at C:\Program Files\MadCap Software\MadCap Flare V4\Flare.app\Resources\WebHelp (for v5 it's the same location, but with V5 in the middle instead of V4). Make copies of the two files (just in case), then open the files in Notepad and add the doctype declaration. (The _Left.htm file is apparently generated at build time so no need to make the mod there.)

Making the change to those files will apply to all projects generated in Flare. If there are some projects where you can't have that doctype or have to have another one, then you'll have to go the after-build modification for them.
Image

Lisa
Eagles may soar, but weasels aren't sucked into jet engines.
Warning! Loose nut behind the keyboard.
TheGreatAndPowerfulOz
Sr. Propeller Head
Posts: 131
Joined: Mon Apr 24, 2006 12:52 pm
Location: Glen Mills, PA

Re: XML prolog before DOCTYPE declaration: trouble for IE6

Post by TheGreatAndPowerfulOz »

Lisa,

Thanks for the continued effort to help. But, alas, the 'default.htm' frameset page generated in the output directory already has its own DOCTYPE declaration of:

Code: Select all

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
... (this is regardless of whether or not the "Add DOCTYPE delcaration to generated topics" option is selected for the target).

I attempted to replace it with a "strict"-type declaration, but to no avail. I actually wouldn't have expected a page in a frameset to "inherit" the DOCTYPE specification from its parent, anyway. I'm thinking that IE6 will always run in quirks mode for any given page, unless told otherwise by that page's DOCTYPE declaration.

I'll keep tinkering with it. I'm hoping I'll discover some way to modify the JS to work in quirks mode, or that all my users will just ditch IE6 for a later version or a real browser like FF! :-)
Austin Wright

Flare 2022 r3 (18.2.8431.26678) :: TopNav HTML5 / PDF output
RamonS
Senior Propellus Maximus
Posts: 4293
Joined: Thu Feb 02, 2006 9:29 am
Location: The Electric City

Re: XML prolog before DOCTYPE declaration: trouble for IE6

Post by RamonS »

TheGreatAndPowerfulOz wrote:The code to which I refer is Shadowbox, used for viewing of various sorts of online media (http://www.shadowbox-js.com/). I can get by alright with some JS coding, but I'm not an expert by any means. Any suggestions along the lines of what to look for?
I'm in the same boat having not much knowledge about JS. What I do know is that it is the number one cause for slow web page performance. Do you provide the help via web server exclusively? If yes, you might want to look at server side scripting. That is really the place where the dynamics should come from, not from a possible underpowered client system that uses a browser with a really bad JS engine.
Post Reply