By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,738 Members | 1,114 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,738 IT Pros & Developers. It's quick & easy.

Check whether browser is in quirks or standards mode?

P: n/a
Is there any other way apart from:
document.compatMode == 'CSS1Compat'

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<title>Virtual Library</title>
<script type="text/javascript">
<!--
function init(){
window.status='You are in '
+((document.compatMode=='CSS1Compat')?'Standards': 'Quirks')+' mode.'
}
window.onload=init;
//-->
</script>
</head>
<body>
<p>Howdy</p>
</body>
</html>
Apr 4 '07 #1
Share this Question
Share on Google+
22 Replies


P: n/a
Harry Haller wrote:
Is there any other way apart from:
document.compatMode == 'CSS1Compat'
Other way for what? Oh, the question was in the subject field:
Check whether browser is in quirks or standards mode?
No better ways come to mind, but using a bookmarklet would be handier:

http://dorward.me.uk/www/bookmarklets/qors/

Osmo

Apr 4 '07 #2

P: n/a
On 4 Apr, 08:30, Harry Haller <H...@Steppenwolf.comwrote:
Is there any other way apart from:
document.compatMode == 'CSS1Compat'
Just author the document so that it sets the browser into a Standards
mode. This list is obscure, but it's deterministic. A browser doesn't
flip between modes just because it's Thursday.

Apr 4 '07 #3

P: n/a
Harry Haller <Ha***@Steppenwolf.comwrites:
Is there any other way apart from:
document.compatMode == 'CSS1Compat'
Why would you need to check? It's the doctype that *you* wrote that will
determine the mode, not random fluctuations in the space-time continuum.

If you're not sure which doctypes will trigger what modes, have a look at:

<http://hsivonen.iki.fi/doctype/>

sherm--

--
Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net
Apr 4 '07 #4

P: n/a
Scripsit Sherm Pendley:
Why would you need to check? It's the doctype that *you* wrote that
will determine the mode, not random fluctuations in the space-time
continuum.
I can figure out a few reasons, and it was nice to see the info on a
bookmarklet for the purpose.

For example, if you get the job of maintaining a web page created by someone
else, you might want to check first whether it triggers quirks or standards
mode. Of course you can read the doctype declaration, but it might contain a
hard-to-notice type.

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/

Apr 4 '07 #5

P: n/a
On 4 Apr, 12:14, "Jukka K. Korpela" <jkorp...@cs.tut.fiwrote:
Scripsit Sherm Pendley:
Why would you need to check? It's the doctype that *you* wrote that
will determine the mode, not random fluctuations in the space-time
continuum.

I can figure out a few reasons, and it was nice to see the info on a
bookmarklet for the purpose.

For example, if you get the job of maintaining a web page created by someone
else, you might want to check first whether it triggers quirks or standards
mode. Of course you can read the doctype declaration, but it might contain a
hard-to-notice type.

--
Jukka K. Korpela ("Yucca")http://www.cs.tut.fi/~jkorpela/
Maintaining pages created by another coder, who told the browser to
use strict xhtml when there wasn't a hope in hell any browser would do
that for what was actually in the page... seems like a familiar story.

Currently the page header says:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">

Many of my pages have an iframe in them. The W3C validator will
declare this to be invalid (indicating that the browser ought to
switch to quirks mode) but IE6 will happily stay in standards mode
when showing the page. But what will Firefox and IE7 do?

I wrote a bit of javascript that shows the result of
document.compatMode == 'CSS1Compat' when the Ctrl+Shift+s keys are
pressed. It would be nice if the browser makers could include
something like this in their browsers - a key combination which tells
us what mode the browser is in - then people wouldn't have to waste
their time writing test pages to see how things were being rendered.

I posted the code to news:comp.lang.javascript - far more useful than
a million and one test pages - but only if the document.compatMode ==
'CSS1Compat' test actually works for all major browsers.


Apr 4 '07 #6

P: n/a
mark4asp wrote:
>
It would be nice if the browser makers could include
something like this in their browsers - a key combination which tells
us what mode the browser is in
Gecko browsers have had this forever - CTRL+I (i.e. Page Info)
The rendering mode is shown in the first tab.

--
Berg
Apr 4 '07 #7

P: n/a
On 4 Apr, 12:14, "Jukka K. Korpela" <jkorp...@cs.tut.fiwrote:
For example, if you get the job of maintaining a web page created by someone
else, you might want to check first whether it triggers quirks or standards
mode.
Most decent browsers, View Page Info

You don't need to embed such a tool _within_ each page.

Apr 4 '07 #8

P: n/a
Scripsit Andy Dingley:
On 4 Apr, 12:14, "Jukka K. Korpela" <jkorp...@cs.tut.fiwrote:
>For example, if you get the job of maintaining a web page created by
someone else, you might want to check first whether it triggers
quirks or standards mode.

Most decent browsers, View Page Info
Quirks mode is basically a matter of simulating bugs in old versions of IE,
so it would be rather relevant to consider IE, too.
You don't need to embed such a tool _within_ each page.
That wasn't suggested by anyone. A scriptlet (bookmarklet, favelet) handles
the issue nicely.

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/

Apr 4 '07 #9

P: n/a
"Jukka K. Korpela" <jk******@cs.tut.fiwrites:
Scripsit Sherm Pendley:
>Why would you need to check? It's the doctype that *you* wrote that
will determine the mode, not random fluctuations in the space-time
continuum.

I can figure out a few reasons, and it was nice to see the info on a
bookmarklet for the purpose.

For example, if you get the job of maintaining a web page created by
someone else, you might want to check first whether it triggers quirks
or standards mode. Of course you can read the doctype declaration, but
it might contain a hard-to-notice type.
Ah yes, of course! I was thinking of new pages - I hadn't considered the
maintenance issue. Very short-sighted of me.

sherm--

--
Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net
Apr 4 '07 #10

P: n/a
On Wed, 04 Apr 2007 07:30:38 GMT
Harry Haller <Ha***@Steppenwolf.comwrote:
Is there any other way apart from:
[...]

Hi,

I could be a little obtuse but does the Web Developer Toolbar not have
a handy little button that tells the 'Render Mode' of each page being
viewed as either 'Standards Compliance Mode' or 'Quirks Mode'? It seems
fairly accurate but I do not know the actual mechanism that it uses to
calculate this.

http://chrispederick.com/work/webdeveloper/

Andrew
--
Andrew's Corner
http://people.aapt.net.au/~adjlstrong/
Apr 4 '07 #11

P: n/a
Wed, 04 Apr 2007 07:30:38 GMT from Harry Haller
<Ha***@Steppenwolf.com>:
Is there any other way apart from:
document.compatMode == 'CSS1Compat'
Wrong newsgroup. This is an HTML newsgroup. I can guess what the
above is, but it's not HTML.
--
Stan Brown, Oak Road Systems, Tompkins County, New York, USA
http://OakRoadSystems.com/
HTML 4.01 spec: http://www.w3.org/TR/html401/
validator: http://validator.w3.org/
CSS 2.1 spec: http://www.w3.org/TR/CSS21/
validator: http://jigsaw.w3.org/css-validator/
Why We Won't Help You:
http://diveintomark.org/archives/200..._wont_help_you
Apr 5 '07 #12

P: n/a
In article <46***********************@news.fv.fi>,
Osmo Saarikumpu <os**@weppipakki.comwrote:
Harry Haller wrote:
Is there any other way apart from:
document.compatMode == 'CSS1Compat'

Other way for what? Oh, the question was in the subject field:
Check whether browser is in quirks or standards mode?

No better ways come to mind, but using a bookmarklet would be handier:

http://dorward.me.uk/www/bookmarklets/qors/
Nice idea, but bookmarklets (like many Javascript/JScript/ECMAScript
items) don't always work the same in different browsers. I imagine it is
intended to work in IE. It appears to work in Opera. It isn't needed in
Firefox. This bookmarklet always returns Quirks mode in Safari, for
example, regardless of actual browser mode.

--
http://www.ericlindsay.com
Apr 5 '07 #13

P: n/a
Bergamot wrote:
>It would be nice if the browser makers could include
something like this in their browsers - a key combination which tells
us what mode the browser is in

Gecko browsers have had this forever - CTRL+I (i.e. Page Info)
The rendering mode is shown in the first tab.
Unfortunately in Firefox Ctrl+I don't trigger the page info dialogbox
anymore : instead it brings the bookmarks sidebar. Very, very annoying !

There was an extension to get the old behavior back - it was named
Pithy. But that extension isn't maintained and is not compatible since
Firefox 1.5 at least
Apr 5 '07 #14

P: n/a
Scripsit Pierre Goiffon:
Unfortunately in Firefox Ctrl+I don't trigger the page info dialogbox
anymore : instead it brings the bookmarks sidebar. Very, very
annoying !
It's a bit annoying, but I can get the Page Info on my Firefox using just
three keys (which is more than two, but not very very much more): Alt+Y T.
Your mileage surely varies: you need to check which letters are underlined
in the command menu items that you use to access Page Info.

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/

Apr 5 '07 #15

P: n/a
Pierre Goiffon wrote:
Bergamot wrote:
>>
Gecko browsers have had this forever - CTRL+I (i.e. Page Info)

Unfortunately in Firefox Ctrl+I don't trigger the page info dialogbox
anymore
They change a lot of things in Firefox (I believe it was even CTRL+J for
a while). Look around the menus and you should find it.
instead it brings the bookmarks sidebar. Very, very annoying !
Tis a problem with pretty much any software that gets updated - stuff
changes unexpectedly. Often it's good, sometimes it isn't. Frankly, I
don't like much of anything about Firefox. In mozilla's zealousness to
have a leaner browser, they dropped many things from the standard
toolbars that I use often, making it very cumbersome to use. Seamonkey
has had its ups and downs, but overall it's better, at least for me.
There was an extension to get the old behavior back - it was named
Pithy.
The Web Developer toolbar also has an option to show Page Info, but I
don't see a keyboard shortcut for it.

--
Berg

Apr 5 '07 #16

P: n/a
On Wed, 04 Apr 2007 07:06:25 -0400, Sherm Pendley
<sp******@dot-app.orgwrote:
>Harry Haller <Ha***@Steppenwolf.comwrites:
>Is there any other way apart from:
document.compatMode == 'CSS1Compat'

Why would you need to check? It's the doctype that *you* wrote that will
determine the mode, not random fluctuations in the space-time continuum.
No, it isn't. It's the DOCTYPE in combination with the HTML in
combination with the browser.

I set my pages to HTML 4.01 strict, write suitable HTML and hope for
the best. I've noticed that a HTML 4.01 strict page containing an
iframe fails W3C validation - but nevertheless, IE6 and Firefox stay
in standards mode when confronted by such a page (as I hope IE7 does
too - yet to test it).

for example:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd"><html>
<head>
<meta http-equiv="content-type"
content="text/html;charset=utf-8" />
<title>Test Page</title>
</head>
<body>
<p>Test page</p>
<iframe scrolling="no" src="EmbeddedPage.html"></iframe>
</body>
</html>
>If you're not sure which doctypes will trigger what modes, have a look at:

<http://hsivonen.iki.fi/doctype/>

sherm--
Apr 6 '07 #17

P: n/a
On Fri, 06 Apr 2007 08:17:19 GMT, Harry Haller <Ha***@Steppenwolf.com>
wrote:
>>Why would you need to check? It's the doctype that *you* wrote that will
determine the mode, not random fluctuations in the space-time continuum.

No, it isn't. It's the DOCTYPE in combination with the HTML in
combination with the browser.
What HTML is there that will change a browser's rendering mode, for a
doctype declaration, content-type and xml prolog (or lack of) that
otherwise puts it into a standards mode?
Apr 6 '07 #18

P: n/a
Andy Dingley wrote:
What HTML is there that will change a browser's rendering mode, for a
doctype declaration, content-type and xml prolog (or lack of) that
otherwise puts it into a standards mode?
Finally an easy question from somebody :)

Try:

<!-- Change to quirks mode. -->

with IE6 before doctype.

Tested with bookmarklet :)

Osmo

Apr 7 '07 #19

P: n/a
Eric Lindsay <NO*************@ericlindsay.comwrites:
This bookmarklet always returns Quirks mode in Safari, for
example, regardless of actual browser mode.
Safari doesn’t have a compatMode property for the document object and
consequently returns 'undefined'. That’s simply a flaw in the
bookmarklet (which just checks for a particular return string and
assumes 'else' a substantial condition), it would be fairly trivial to
do a feature test first and issue an appropriate message. FWIW.
--
||| hexadecimal EBB
o-o decimal 3771
--oOo--( )--oOo-- octal 7273
205 goodbye binary 111010111011
Apr 10 '07 #20

P: n/a
Andy Dingley <di*****@codesmiths.comwrites:
What HTML is there that will change a browser's rendering mode, for a
doctype declaration, content-type and xml prolog (or lack of) that
otherwise puts it into a standards mode?
Client-side software can fiddle with the end user output to no end,
e.g. inserting a comment declaration with special script features
(killing various incoming script goodies and the likes) in the
prolog. That’s not even technically wrong as long as it doesn’t preceed
an SGML or XML declaration (the “xml prolog” is mostly safe, depending
on the phase of the moon).
--
||| hexadecimal EBB
o-o decimal 3771
--oOo--( )--oOo-- octal 7273
205 goodbye binary 111010111011
Apr 10 '07 #21

P: n/a
On 10 Apr, 02:55, Eric B. Bednarz <bedn...@fahr-zur-hoelle.orgwrote:
Andy Dingley <ding...@codesmiths.comwrites:
What HTML is there that will change a browser's rendering mode,
Client-side software can fiddle with the end user output to no end,
Does the rendering mode ever change after the page has first been
loaded, in response to client-side changes? Or is the mode stuck
forever, while the page changes beneath it?

Apr 10 '07 #22

P: n/a
"Andy Dingley" <di*****@codesmiths.comwrites:
Does the rendering mode ever change after the page has first been
loaded, in response to client-side changes? Or is the mode stuck
forever, while the page changes beneath it?
I’m not sure what you are asking. Once everything is loaded – including
any client side preprocessing of sorts – the rendering mode is a fait
accompli. With the caveat that ‘everything’ might not be identical with
what the author intended, possibly including the rendering mode.

What do you mean by “changes beneath”? The compatMode property – if
available at all – is readonly, so you cannot change that after the
fact with [expand politically correct list of aliases for javascript
here].

I could wildly imagine that bozo ‘security’ software reacts on script
execution in a way that forces a reload (new game, new cards), but
I’ve never seen or heard of anything like that. Which is not to say that
it doesn’t exist, I’ve seen desktop ‘firewalls’ do *much* worse things.

--
||| hexadecimal EBB
o-o decimal 3771
--oOo--( )--oOo-- octal 7273
205 goodbye binary 111010111011
Apr 11 '07 #23

This discussion thread is closed

Replies have been disabled for this discussion.