How to detect the rendering mode which the browser is currently in (works for IE6).

M

mark4asp

<!--
// How to detect the rendering mode which the browser is currently in
(works for IE6).
// Ctrl+Shift+s displays indicates whether the browser is in quirks or
standards mode.

// Detect keypress
var captureKeys = function(ev) {
ev = ev || window.event; // gets the event in ie or ns
kCode = ev.keyCode || ev.which; // gets the keycode in ie or ns

/* in ie, when pressing the ctrl + shift + key, it gives the key code
for the capitalized key (probably because shift is pressed)
in ns pressing ctrl, shift and another key doesn't change the
keycode
thus, the || and two different numbers */

if (ev.ctrlKey && ev.shiftKey && kCode == 19 || ev.ctrlKey &&
ev.shiftKey && kCode == 83)
{ // ctrl+alt+s
ShowStatus(); // function to show browser compatibility mode
return false; // make it so the browser ignores key combo
}
if (ev.ctrlKey && kCode == 119) { // ctrl+w
closeWin(); // run your own script to close the window
// doesn't work in ie, ie just closes the window
return false;
}
}
function ShowStatus()
{
window.status = "This browser is using "+
((document.compatMode=='CSS1Compat')?"'standards'":"'quirks'")+"
mode.";
}

function init()
{
document.onkeypress=captureKeys;
}

window.onload=init;
//-->
 
G

Gary Hasler

mark4asp said:
<!--
// How to detect the rendering mode which the browser is currently in
(works for IE6).
// Ctrl+Shift+s displays indicates whether the browser is in quirks or
standards mode.....

With IE 6, I think you can also tell if you're in quirks mode by whether
the window chrome has a 'raised' look on its inside edge. Or am I
imagining it?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,738
Latest member
JinaMacvit

Latest Threads

Top