问题描述
我已经创建了一个Windows 8项目使用phonegap 2.9.0,然后尝试使用JQuery移动库内。但我得到以下安全异常。任何想法如何解决这个问题。
I have created a windows 8 project using the phonegap 2.9.0 and then tried to use JQuery mobile library within it. But I get the following security exception. Any idea how to resolve this ?.
Exception was thrown at line 4, column 7009 in ms-appx://c6a291ce-903f-47ab-b167- cb8378ffb051/www/libs/jquery.core/jquery-1.9.1.min.js
0x800c001c - JavaScript runtime error: Unable to add dynamic content. 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.
If there is a handler for this exception, the program may be safely continued.
推荐答案
我刚刚遇到同样的问题。看来,事情的根本在于WinJS安全模型将不允许JQuery dom操纵,当您从字符串中创建元素,例如。使用.html()方法。
I have just run into the same problem. It appears that the grist of the matter is that the WinJS security model won't allow the JQuery dom manipulation when you create elements from strings e.g. using the .html() method.
有关详细信息,请参阅以下内容:
See the below for more information:http://blogs.msdn.com/b/windowsappdev/archive/2013/04/01/windows-store-app-support-in-jquery-version-2-0.aspx
总之,聪明的人已经在JQuery 2.0中修复此问题。
In summary the clever people have produced a fix to this in JQuery 2.0.
所以我将使用JQuery 2.0,但它将与JQuery Mobile?我还没有确定,所以我可能看看完全建立和附加dom元素,而不是使用.html()方法。
So I'll be looking at using JQuery 2.0 but will it work with JQuery Mobile? I haven't determined that yet so I'll probably look at fully building and attaching the dom elements rather than using the .html() method.
但请注意,我没有尝试过任何这些方法,所以不能保证它们的有效性。
But please note that I have not tried any of these approaches yet so cannot vouch for their validity.
这篇关于Windows 8 Phonegap应用程序JQuery Mobile Security异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!