簡體   English   中英

Worklight應用程序在Windows 8上崩潰

[英]Worklight app crashes on Windows 8

我正在使用Worklight 5.0.6開發一個應用程序。 該應用針對平板電腦(iOS,Android和Windows)。 該應用程序在iOS和Android上運行良好,但我無法在Windows 8上正常運行。當我點擊鏈接時應用程序崩潰。 以下是錯誤消息的一部分:

"HTML1701: Unable to add dynamic content '  <link/><table></table><a href='/a'>a</a><input type='checkbox'/>'. A script attempted to inject dynamic content or elements previously modified dynamically that might be unsafe. For example, using the innerHTML property to add script or malformed HTML will generate this exception. Use the toStaticHTML method to filter dynamic content or explicitly create elements and attributes with a method such as createElement. For more information, see http://go.microsoft.com/fwlink/?LinkID=247104."

應用程序應該在單擊鏈接時注入html片段。 我正在使用以下函數將html注入元素:

function loadPartial(path, elementId)
{
    $.get(path, function (data) {
        $(elementId).html(data).trigger("create");
        $("#my-navbar > ul").removeClass("ui-grid-a");
        if (!hideDuringFocus)
        {
            $("[data-role=header]").fixedtoolbar({ hideDuringFocus: "" });
            $("[data-role=footer]").fixedtoolbar({ hideDuringFocus: "" });
        }
    });
}

function loadPartialWithFunction(path, elementId, aFunction)
{
    $.get(path, function (data) {
        $(elementId).html(data).trigger("create");
        $("#my-navbar > ul").removeClass("ui-grid-a");
        if (!hideDuringFocus)
        {
            $("[data-role=header]").fixedtoolbar({ hideDuringFocus: "" });
            $("[data-role=footer]").fixedtoolbar({ hideDuringFocus: "" });
        }
        aFunction();
        });
} 

我在代碼中犯了錯誤嗎? 任何幫助,將不勝感激。 如果需要更多信息或源代碼,請與我們聯系。

這個問題已經解決了,謝謝。 我必須使用MSApp.execUnsafeLocalFunction包裝代碼,所以它看起來像這樣:

function loadPartialWithFunction(path, elementId, aFunction)
{
    $.get(path, function (data) {
        MSApp.execUnsafeLocalFunction(function(){
            $(elementId).html(data).trigger("create");
            $("#my-navbar > ul").removeClass("ui-grid-a");
            if (!hideDuringFocus)
            {
                $("[data-role=header]").fixedtoolbar({ hideDuringFocus: "" });
                $("[data-role=footer]").fixedtoolbar({ hideDuringFocus: "" });
            }
            aFunction();
       });
    });
}  

這是Win8 Metro上的jQuery問題。 Metro應用程序具有動態內容限制,需要先繞過。 這是一個堆棧溢出問題,為此問題提供了大量答案:

在Windows 8 Metro JavaScript App中使用jQuery會導致安全性錯誤

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM