Forum Moderators: open

Message Too Old, No Replies

How can I determine the docType in Safari?

         

SilverLining

9:19 am on May 18, 2007 (gmt 0)

10+ Year Member



I have used this favlet
javascript:alert(document.compatMode);
to determine if IE is forced into Quirks mode. IE and Firefox now displays a JS alert box with "CSS1Complat" which I understand to be Standards Compliant Mode. Is this correct? Quirks mode displays "Backpat".

When pasting this JavaScript into Safari it just displays and alert box with the message "Undefined". How can I tell what mode Safari renders the page in? The reason being that Safari displays some pages perfectly (with a 100% height background image), and others not 100% height. My main question however is to determine the docType, so please don't focus on the height issue. Thanks.

Added:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<?xml version="1.0" encoding="iso-8859-1"?>

[edited by: SilverLining at 9:22 am (utc) on May 18, 2007]

JAB Creations

9:23 pm on May 18, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Safari probably does not support that JavaScript property.

A more friendly method to detect the rendering mode...

<a href="#" onclick="javascript:m= ( document.compatMode == 'CSS1Compat' )? 'Standards' : 'Quirks'; window.alert('Page rendered in '+m+'-mode.'); return false;">Detect Render Mode</a>

I'm not sure about Safari's rendering mode, don't have a grand for a MAC. If you're using it you could try viewing the page's properties, information, or hover your mouse over it's TAB like in Opera or Gecko though these are just guesses.

XHTML is a subset of XML so you should not logically serve the XML declaration after the DTD declaration but before it.

- John

SilverLining

10:01 am on May 19, 2007 (gmt 0)

10+ Year Member



Thanks John. I'll give that a go.

Initially I had the XML declaration before the DTD, but according to Setek's post [webmasterworld.com] (post #3259606) on the CSS forum, this forces IE into Quirks mode and for that reason I changed the order of the two.

SilverLining

10:16 am on May 19, 2007 (gmt 0)

10+ Year Member



Safari is rendered in Quirks-mode. Firefox and IE are rendered in Standards-mode. Now that I know that, I just need to find out why. Thanks very much for the JavaScript you provided.

encyclo

12:36 pm on May 19, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



An XML declaration can only be placed on the first line... but that pushes IE6 into quirks mode. However, you're not using XML as such, so the declaration has no real meaning. Just get rid of it altogther, and declare your charset with a meta charset element or via a HTTP header.

The fact that the XML declaration is incorrectly placed under the doctype (causing a parsing error) is the most likely reason why Safari is using quirks mode.

SilverLining

8:36 am on May 21, 2007 (gmt 0)

10+ Year Member



encyclo I thought that fixed it, but when swapping the order to list the XML declaration first, Safari still renders in Quirks mode. We do serve XML content, so do need the XML declaration.

[edited by: SilverLining at 8:51 am (utc) on May 21, 2007]