473,387 Members | 1,844 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Check whether browser is in quirks or standards mode?

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
22 13514
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
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
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
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
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
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
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
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
"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
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
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
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
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
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
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
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
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
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
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
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
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
"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Nathan Wallace | last post by:
When in quirks mode, IE seems to be able to display pages without any vertical scrollbar: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <style> body {...
5
by: davesuemcbride | last post by:
Hi All, I built a great looking page to learn CSS, using div's for 'rows' and span's for 'columns' - nice complex layout where I could create just about anything by endlessly nesting them as...
4
by: Dr. StrangeDub | last post by:
I am part of a group that has developed an ASP.Net web application. I am looking for a way to determine whether or not the browser is actually running on the web server. For this case (when...
3
by: Ollie | last post by:
Can you check whether a users browser allows you to use cookies? Cheers Ollie
2
by: kaczmar2 | last post by:
I have a webpage that has 2 main DIVs - a title div and a content div. I want the title dive to always "stick to the top of the page and not scroll, regardless of the size of the window. The...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.