打开文档时,Windows HTML5应用程序中出现“DOCTYPE expected”错误

时间:2016-01-25 10:23:16

标签: jquery windows html5 doctype windows-applications

我在Visual Studio中使用Javascript和HTML5 创建 Windows 8.1 App。所以,要从我正在使用的网站上打开文件。

这是我的HTML代码:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>JS_BlankApp</title>
    <script src="/js/default.js"></script>
</head>
<body class="phone">
    <div>
        <x-ms-webview id="webview" src="http://google.com" width="300" height="300"></x-ms-webview>
    </div>
     <div style="background-color:yellow">
        <a href="#" id="OpenDocument">Click here to open the document</a>
    </div>
</body>
</html>

这是我的Javascript代码:

(function () {
    "use strict";
    var app = WinJS.Application;
    var activation = Windows.ApplicationModel.Activation;

    app.onactivated = function (args) {
        if (args.detail.kind === activation.ActivationKind.launch) {
            if (args.detail.previousExecutionState !== activation.ApplicationExecutionState.terminated) {

                $(document).ready(function () {
                    $("#OpenDocument").click(function () {
                        //$("webview").attr("src", m");
                        webview.navigate("https://docs.oracle.com/cd/E13226_01/workshop/docs81/pdf/files/workshop/JavaKeywordReference.pdf")
                    });
                });

            } else {
            }
            args.setPromise(WinJS.UI.processAll());
        }
    };

    app.oncheckpoint = function (args) {

    };
    app.start();
})();

问题是当我点击“OpenDocument”链接时,我在控制台窗口中出现以下错误:

  

HTML1527:期望DOCTYPE。考虑添加有效的HTML5文档类型:   “”。

有人可以告诉我,我在做什么。

1 个答案:

答案 0 :(得分:0)

我认为这是一个本地问题,因为我无法复制它。删除<!DOCTYPE html>可以解决问题。