Is your console showing an error message about an incompatible IE Document Mode?

I am encountering an issue with the following code in my jsp page.

<!--[if lt IE 7]><html lang="en" class="no-js lt-ie10 lt-ie9 lt-ie8 lt-ie7" xml:lang="en" xmlns:fb="http://www.facebook.com/2008/fbml"> <![endif]-->
<!--[if IE 7]><html lang="en" class="no-js lt-ie10 lt-ie9 lt-ie8" xml:lang="en" xmlns:fb="http://www.facebook.com/2008/fbml"> <![endif]-->
<!--[if IE 8]><html lang="en" class="no-js lt-ie10 lt-ie9" xml:lang="en" xmlns:fb="http://www.facebook.com/2008/fbml"> <![endif]-->
<!--[if IE 9]><html lang="en" class="no-js lt-ie10" xml:lang="en" xmlns:fb="http://www.facebook.com/2008/fbml"> <![endif]-->
<!--[if gt IE 9]><!--><html lang="en" class="no-js" xmlns="http://www.w3.org/1999/html" xml:lang="en" xmlns:fb="http://www.facebook.com/2008/fbml"> <!--<![endif]-->

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
    "http://www.w3.org/TR/html4/strict.dtd">
<html>

  //some code

</html>

Although this code functions correctly in IE7 and other browsers, it is causing an error in IE9 as indicated below in the IE console:

LOG : Incompatible IE Document Mode

I am seeking assistance in resolving this issue.

Thank you!

Answer №1

It is important to note that the doctype declaration should always be included as the first line in your HTML file. Additionally, having multiple opening HTML tags within IE conditionals can lead to complications.

If you are considering cross-browser compatibility beyond just IE, it may not be ideal to wrap the HTML tag with conditionals. Other browsers will simply ignore these conditional comments, making it difficult to define specific classes for them.

An alternative approach could involve adding all necessary classes directly to the HTML tag and then selectively importing CSS files based on the version of IE being used. These CSS files can define the required classes for each browser version, such as ltIE7.css for .lt-ie7 class, ltIE8.css for .lt-ie8 class, and so on.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
    "http://www.w3.org/TR/html4/strict.dtd">
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<html class="no-js lt-ie10 lt-ie9 lt-ie8 lt-ie7" lang="en" xml:lang="en" xmlns:fb="http://www.facebook.com/2008/fbml">
    <head>
        <!--[if lt IE 7]><link rel="stylesheet" type="text/css" href="ltIE7.css"/><![endif]-->
        <!--[if lt IE 8]><link rel="stylesheet" type="text/css" href="ltIE8.css"/><![endif]-->
        <!--[if lt IE 9]><link rel="stylesheet" type="text/css" href="ltIE9.css"/><![endif]-->
        <!--[if lt IE 10]><link rel="stylesheet" type="text/css" href="ltIE10.css"/><![endif]-->
    </head>
    <body>
        ...
    </body>
</html>

Another option, if external CSS files are not preferred, is to define the necessary classes inline using conditional comments within the head:

<style type="text/css">
    <!--[if lt IE 7]>
        .lt-ie7 {...}
    <![endif]-->
    <!--[if lt IE 8]>
        .lt-ie8 {...}
    <![endif]-->
    <!--[if lt IE 9]>
        .lt-ie9 {...}
    <![endif]-->
    <!--[if lt IE 10]>
        .lt-ie10 {...}
    <![endif]-->
</style>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Navigating the concepts of NodeJS and AngularJS can be a bit overwhelming

Having recently dabbled in creating simple single page applications using AngularJS without the need for a server, I decided to take a NodeJS course today. As I delved into the course material, something started bothering me. When using NodeJS, I realize ...

Encountering an issue with NPM while attempting to install Parcel

After trying multiple solutions from various online sources, I am still unable to resolve the issue. Any advice or recommendations would be highly appreciated! npm ERR! code 1 npm ERR! path C:\Users\Tarun\Desktop\NamasteReact\node_ ...

Angular JS - Implementing a flexible URL structure for fetching data using $http GET

I have been working on implementing a login feature for my app by using a custom REST API. Initially, I was able to successfully authenticate by manually entering the complete URL with the username and password: http://www.myexample.com/ACTION/USER/PASSWO ...

"Exploring the process of unsubscribing or disposing of an interval observable based on a certain condition in Angular2 or

I am embarking on the journey into Rx and reactive programming, facing a situation that requires me to continuously monitor a hardware's status by sending a POST request to its REST API every 500ms. The goal is to stop the interval observable once the ...

Manipulate documents in a Mongoose array by conditionally adding or removing elements

Upon receiving data from the front end, I am dealing with the following object: { name: "Test 1", sets: [1,2] } Mongo Schema: Sets name: { type: String }, tests : [{ type: Schema.Types.ObjectId, ref : 'Test' ...

What is the most effective method to horizontally center a div element when its width and height are not predetermined

Let's say there is a div element on the page like this: <div class="center"></div> The CSS style for this div may look something like this: .center{ background:red; position:absolute; left:50%; top:50%; margin-left: ...

Using Javascript, delete all chosen HTML elements containing innerText

Looking to extract certain HTML tags from a block of code in TextArea1 and display the modified output in TextArea2 upon clicking a button. <!DOCTYPE html> <html> <head> <title></title> <meta charset="utf-8&quo ...

Is it possible to refresh a div with just one click on an image?

I've tried searching, but I can't seem to find a clear explanation. Here's what I'm trying to achieve: I want to refresh specific divs on my webpage without having to reload the entire page. For example: <div id="topimage"> < ...

What is the best way to assign specific codes to separate pages using a single JS file?

I am currently working on a project that involves an authentication JavaScript which is responsible for managing user sign-ins and registrations. However, there are certain lines of code within this script that impact different pages in various ways. I n ...

What is the best way for me to incorporate images retrieved from an API call into my

Hey everyone, this is my first time posting on here so if there's anything I'm missing, please let me know! I've run into an issue with the images on my categories page not aligning properly and being different sizes after I incorporated som ...

Eliminating empty elements from arrays that are nested inside other arrays

I am facing a challenge with the array structure below: const obj = [ { "description": "PCS ", "children": [ null, { "name": "Son", ...

Transfer an array into data using the POST method

When making a REST API call in CodeIgniter, I encountered an issue with the array format being sent to the server: [{"PMcolor":"Azul tostado","PMpartes":"Un poquito de las orjeas y un bigote a lo Dali, quizas le alegre la cara","PMcosteTotal":"445"}]: Th ...

Utilize background-size:cover and incorporate text in a horizontally scrolling webpage

Struggling to create a minimalist HTML layout with a horizontal scrollbar, featuring a large image on the left and a lengthy text with columns on the right? I suspect the issue lies in the implementation of position:relative with float, as well as position ...

tips on concealing video URL

Is there a way to obscure the URL of a video being displayed on a webpage using the HTML5 Video Player? The video URL is pasted as a <source> element, and I'm unsure how to obfuscate it without causing issues with the player. I'm looking f ...

Use ag-Grid to customize your column headers with checkboxes, allowing you to easily select or deselect all items in that column. This feature is not limited to

In my experience with ag-grid, I often find myself needing to customize the first column header to include a checkbox. This allows me to easily perform actions such as selecting all or deselecting all rows in the grid. It's important to note that this ...

Perform an additional HTTP request and utilize the response within the existing Observable

In my Angular 2 project, I am utilizing the http component to make API calls. The specific REST API I want to access returns a maximum of 100 Elements in one request. If more items exist, a hasMore flag is included in the response. To retrieve additional ...

What is the correct way to assign a $scope variable after a successful ajax call?

Currently, I am working with Symfony and AngularJs 1.6.8 along with Symfony 3.4. Below is the configuration setup that I have: base.html.twig <html lang="en" data-ng-app="CeocApp" ng-controller="CeocController"> //css for the app <link id="ng ...

There appears to be an issue with reading the property 'toLowerCase' of an undefined element, and I'm having trouble identifying the error

The variables I have initialized (globally): var audio; var LANGUAGE; var audioArray; var MEDIAARRAY; var WORDS; var SOUNDARRAY; This specific line is causing the error: var audioId = MEDIAARRAY.audio.lowercase.indexOf(exObject['exerciseGetWordInpu ...

How to retrieve headers using Express.js middleware

My middleware creates authentication API keys that are then added to the header. const loger = require("easy-loger"); require('dotenv').config(); function authMiddleware(req, res, next){ const appApiKey = process.env.API_KEY; l ...

Unable to use jQuery to update a link address

I am currently in the process of developing a Google Analytics plugin and encountering an issue with pagination that relies on Ajax. Each next and previous link triggers a request for data since it serves as the mechanism for pagination. (Problem resolved; ...