Display warning message if Internet Explorer uses Compatibility View mode

<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core">

	<xp:scriptBlock id="scriptBlock1">
			// IE8 compat. mode
			if(navigator.userAgent.indexOf("MSIE 7.0") > 0 && navigator.userAgent.indexOf("Trident/4.0") > 0) {
				dojo.style(dojo.byId('IEcompatwarning'), "display", "block");
			// IE9 compat. mode
			if(navigator.userAgent.indexOf("MSIE 7.0") > 0 && navigator.userAgent.indexOf("Trident/5.0") > 0) {
				dojo.style(dojo.byId('IEcompatwarning'), "display", "block");
			// IE10 compat. mode
			if(navigator.userAgent.indexOf("MSIE 7.0") > 0 && navigator.userAgent.indexOf("Trident/6.0") > 0) {
				dojo.style(dojo.byId('IEcompatwarning'), "display", "block");

		<div id="IEcompatwarning" class="lotusMessage lotusError" style="display: none">
			<img src="/oneuiv2/images/iconError16.png" class="xspImage" />
							<td>Internet Explorer has been set to Compatibility View mode. Please turn this off through Tools - Compatibility View Settings.</td>


Add this custom control to e.g. the top of your front page (or every page) and it will display a warning if Internet Explorer is using Compatibility View mode. The warning message looks like this: http://cl.ly/image/3641200K3M1h

Internet Explorer can run in Compatibility Mode view even though you force IE to use a newer standards mode (by setting X-UA-Compatible to e.g. IE=8). This happens if »Display all websites in Compatibility Mode setting« in Tools - Compatibility View Settings has been set.

Per Henrik Lausten
October 19, 2012 2:40 PM

All code submitted to OpenNTF XSnippets, whether submitted as a "Snippet" or in the body of a Comment, is provided under the Apache License Version 2.0. See Terms of Use for full details.

No comments yetLogin first to comment...