IE10 (9,8) does not recognize DOCTYPE xhtml

28,242

Solution 1

Change your DOCTYPE to:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

(using XHTML strict instead of transitional)

IE10 will stop throwing the error in the console. I'm not sure why IE10 doesn't like transitional XHTML any more. If anyone has a way for IE10 to recognize the XHTML 1.0 Transitional DOCTYPE, that would be awesome.

Solution 2

I was able to get rid of the error by using

<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE9" />

instead of

<meta http-equiv="X-UA-Compatible" content="IE=edge" />

Solution 3

I had same issue. It worth looking at any external libraries you are using. I was using BXSlider and it wasn't happy with jQuery 1.8 on IE10. Due to which IE10 was failing and showing message.

  HTML1524: Invalid DOCTYPE. The shortest valid doctype is "<!DOCTYPE html>

My solution was to upgrade my JQuery to 1.9.1 and also include jQuery migrate.

      <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
      <script src="http://code.jquery.com/jquery-migrate-1.1.0.js"></script>

Hope this helps someone.

Share:
28,242
Peminator
Author by

Peminator

Web-dev in PHP, MySQL, jQuery, liking to use Apache htaccess for cool rewrites ;)

Updated on October 16, 2021

Comments

  • Peminator
    Peminator over 2 years

    IE10 rejects to launch some jQuery code, as far I found on runtime somewhere a doctype is wrong detected and prepended with 4.01 transitional version.

    In IE's developer tools viewing the console I see HTML1524: Invalid DOCTYPE. The shortest valid doctype is "<!DOCTYPE html>" and following (runtime modified) html:

    I believe both misuse of DOCTYPE and some jQuery not working have a common reason, but did not find what it is.

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><HTML 
    xmlns="http://www.w3.org/1999/xhtml" slick-uniqueid="1"><HEAD><META 
    content="IE=10.000" http-equiv="X-UA-Compatible">
    
    <META http-equiv="X-UA-Compatible" content="IE=edge">
    <META http-equiv="Content-Type" content="text/html; charset=windows-1250">
    <TITLE>....
    

    While IE states to run in standards mode, still some things do not work (mainly replacing the links with jQuery's on click events to show content instead loading whole new page - used for unpacking other menu branch using accordion, original links in category headers with href are fallback only for case jQuery fails to animate accordion)

    Too many other on click events or jQuery UI functions to make link to look like button fail to function in IE while working in other browsers.

    Original HTML as provided from server is following:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="sk" lang="sk">
    <head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1250" />
    <title>...
    

    I am forced to use both MooTools and jQuery and know the slick-uniqueid in htm attributes is from Moo, I don't know if it may be the same who edits the doctype, but I'm sure it happens in IE browsers only, Chrome and Firefox just work OK.

    jQuery scripts are loaded from external js file, wrapped in jQuery(function() {.. and all use full variable name jQuery instead of dollarsign, for example jQuery("#myid").click( function(e){...

    As using both mootools and jQuery (I know I should not but need some mootools plugin for slideshow with thumbnails and KenBurns effect) and jQuery is loaded first and within scripts I use only jQuery()... so the $ dollarsign is all free for MooTools to use later on as it is loaded just if needed, within the body (not sure that's OK but that's the way how 'visualslideshow' presented it).

    I'd be glad to hear any ideas or suggestions on how to identify or fix it to get the jQuery working right (v1.8).