2013-06-24 2 views
1

Worklight 5.0.6을 사용하는 앱을 개발하고 있습니다. 앱은 태블릿 (iOS, Android 및 Windows)을 타겟팅합니다. 앱이 iOS 및 Android에서 제대로 작동하지만 Windows 8에서 정상적으로 실행되는 데 문제가 있습니다. 링크를 클릭하면 앱이 다운됩니다. 다음은 오류 메시지의 일부입니다.Windows 8에서 Worklight 앱이 작동하지 않습니다.

"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(); 
     }); 
} 

코드 작성시 실수가 있습니까? 어떤 도움을 주시면 감사하겠습니다. 자세한 정보 나 소스 코드가 필요한지 알려주십시오.

답변

2

, 감사 : 여기에이 문제에 대한 답변을 많이 가진 스택 오버플로 질문입니다. 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(); 
     }); 
    }); 
} 
+0

좋은 정보입니다. 감사. 가능한 경우 Answered로 표시하십시오. –

관련 문제