Check whether browser is in quirks or standards mode?
Question posted by: Harry Haller
(Guest)
on
April 4th, 2007 07:35 AM
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>
Would you like to answer this question?
Sign up for a free account, or Login (if you're already a member).
|
|
April 4th, 2007 08:05 AM
# 2
|
Re: Check whether browser is in quirks or standards mode?
Harry Haller wrote:
Quote:
Originally Posted by
Is there any other way apart from:
document.compatMode == 'CSS1Compat'
|
Other way for what? Oh, the question was in the subject field:
Quote:
Originally Posted by
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
|
|
April 4th, 2007 09:45 AM
# 3
|
Re: Check whether browser is in quirks or standards mode?
On 4 Apr, 08:30, Harry Haller <H...@Steppenwolf.comwrote:
Quote:
Originally Posted by
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.
|
|
April 4th, 2007 11:15 AM
# 4
|
Re: Check whether browser is in quirks or standards mode?
Harry Haller <Harry@Steppenwolf.comwrites:
Quote:
Originally Posted by
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
|
|
April 4th, 2007 11:15 AM
# 5
|
Re: Check whether browser is in quirks or standards mode?
Scripsit Sherm Pendley:
Quote:
Originally Posted by
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/
|
|
April 4th, 2007 01:45 PM
# 6
|
Re: Check whether browser is in quirks or standards mode?
On 4 Apr, 12:14, "Jukka K. Korpela" <jkorp...@cs.tut.fiwrote:
Quote:
Originally Posted by
Scripsit Sherm Pendley:
>
Quote:
Originally Posted by
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.
|
|
April 4th, 2007 02:05 PM
# 7
|
Re: Check whether browser is in quirks or standards mode?
mark4asp wrote:
Quote:
Originally Posted by
>
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
|
|
April 4th, 2007 02:35 PM
# 8
|
Re: Check whether browser is in quirks or standards mode?
On 4 Apr, 12:14, "Jukka K. Korpela" <jkorp...@cs.tut.fiwrote:
Quote:
Originally Posted by
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.
|
|
April 4th, 2007 04:45 PM
# 9
|
Re: Check whether browser is in quirks or standards mode?
Scripsit Andy Dingley:
Quote:
Originally Posted by
On 4 Apr, 12:14, "Jukka K. Korpela" <jkorp...@cs.tut.fiwrote:
>
Quote:
Originally Posted by
>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.
Quote:
Originally Posted by
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/
|
|
April 4th, 2007 05:15 PM
# 10
|
Re: Check whether browser is in quirks or standards mode?
"Jukka K. Korpela" <jkorpela@cs.tut.fiwrites:
Quote:
Originally Posted by
Scripsit Sherm Pendley:
>
Quote:
Originally Posted by
>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
|
|
April 4th, 2007 10:55 PM
# 11
|
Re: Check whether browser is in quirks or standards mode?
On Wed, 04 Apr 2007 07:30:38 GMT
Harry Haller <Harry@Steppenwolf.comwrote:
Quote:
Originally Posted by
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/
|
|
April 5th, 2007 02:55 AM
# 12
|
Re: Check whether browser is in quirks or standards mode?
Wed, 04 Apr 2007 07:30:38 GMT from Harry Haller
<Harry@Steppenwolf.com>:
Quote:
Originally Posted by
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/20...e_wont_help_you
|
|
April 5th, 2007 03:45 AM
# 13
|
Re: Check whether browser is in quirks or standards mode?
In article <46135b42$0$31515$9b536df3@news.fv.fi>,
Osmo Saarikumpu <osmo@weppipakki.comwrote:
Quote:
Originally Posted by
Harry Haller wrote:
>
Quote:
Originally Posted by
Is there any other way apart from:
document.compatMode == 'CSS1Compat'
|
>
Other way for what? Oh, the question was in the subject field:
>
Quote:
Originally Posted by
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
|
|
April 5th, 2007 08:05 AM
# 14
|
Re: Check whether browser is in quirks or standards mode?
Bergamot wrote:
Quote:
Originally Posted by
Quote:
Originally Posted by
>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
|
|
April 5th, 2007 08:25 AM
# 15
|
Re: Check whether browser is in quirks or standards mode?
Scripsit Pierre Goiffon:
Quote:
Originally Posted by
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/
|
|
April 5th, 2007 01:05 PM
# 16
|
Re: Check whether browser is in quirks or standards mode?
Pierre Goiffon wrote:
Quote:
Originally Posted by
Bergamot wrote:
Quote:
Originally Posted by
>>
>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.
Quote:
Originally Posted by
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.
Quote:
Originally Posted by
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
|
|
April 6th, 2007 08:25 AM
# 17
|
Re: Check whether browser is in quirks or standards mode?
On Wed, 04 Apr 2007 07:06:25 -0400, Sherm Pendley
<spamtrap@dot-app.orgwrote:
Quote:
Originally Posted by
>Harry Haller <Harry@Steppenwolf.comwrites:
>
Quote:
Originally Posted by
>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>
Quote:
Originally Posted by
>If you're not sure which doctypes will trigger what modes, have a look at:
>
<http://hsivonen.iki.fi/doctype/>
>
>sherm--
|
|
|
April 6th, 2007 09:35 AM
# 18
|
Re: Check whether browser is in quirks or standards mode?
On Fri, 06 Apr 2007 08:17:19 GMT, Harry Haller <Harry@Steppenwolf.com>
wrote:
Quote:
Originally Posted by
Quote:
Originally Posted by
>>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?
|
|
April 7th, 2007 09:45 AM
# 19
|
Re: Check whether browser is in quirks or standards mode?
Andy Dingley wrote:
Quote:
Originally Posted by
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
|
|
April 10th, 2007 01:45 AM
# 20
|
Re: Check whether browser is in quirks or standards mode?
Eric Lindsay <NOwebmasterSPAM@ericlindsay.comwrites:
Quote:
Originally Posted by
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
|
|
April 10th, 2007 02:05 AM
# 21
|
Re: Check whether browser is in quirks or standards mode?
Andy Dingley <dingbat@codesmiths.comwrites:
Quote:
Originally Posted by
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
|
|
April 10th, 2007 08:55 AM
# 22
|
Re: Check whether browser is in quirks or standards mode?
On 10 Apr, 02:55, Eric B. Bednarz <bedn...@fahr-zur-hoelle.orgwrote:
Quote:
Originally Posted by
Andy Dingley <ding...@codesmiths.comwrites:
Quote:
Originally Posted by
What HTML is there that will change a browser's rendering mode,
|
|
Quote:
Originally Posted by
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?
|
|
April 11th, 2007 12:35 AM
# 23
|
Re: Check whether browser is in quirks or standards mode?
"Andy Dingley" <dingbat@codesmiths.comwrites:
Quote:
Originally Posted by
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
Not the answer you were looking for? Post your question . . .
173,562 Experts ready to help you find a solution.
Sign up for a free account, or Login (if you're already a member).
|
|
|
Top Community Contributors
|