سؤال

Just bumped into this issue and I'm completely taken aback. Unsure how something like that would happen.

The web application is being generated using ASP.NET MVC 3. The doctype is set in the master page:

<%@ Master Language="C#" Inherits="System.Web.UI.MasterPage" %>

<!DOCTYPE html>

<html>
<head runat="server">
    <title><asp:ContentPlaceHolder ID="TitleContentRoot" runat="server" /></title>
    <asp:ContentPlaceHolder ID="CssContentRoot" runat="server">
    </asp:ContentPlaceHolder>

    <script type="text/javascript">
        console.log(document.doctype.name);
    </script>
</head>

On a given page in the application, I call this:

console.log(document.doctype.name);

In the latest Google Chrome, FireFox, and IE10/9 -- all output html.

IE8, like a champ, spits out an error indicating that doctype is undefined:

Unable to get property 'name' of undefined or null reference

I'm not turning up anything in Google searches regarding something like this. Does anyone have any ideas which I could explore? Right now I am looking at possibly the MVC3 master page rendering incorrectly in IE8.

This happens even if I'm on an entirely blank, new project page with no master page, but does not happen in JS fiddle. Hmm

هل كانت مفيدة؟

المحلول

From http://www.w3schools.com/jsref/prop_document_doctype.asp

Note: In Internet Explorer 8 and earlier, this property returns null for HTML and XHTML documents, and will only work for XML documents.

Sorry, looks like it just isn't supported.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top