Windows 8 Phonegap应用程序JQuery Mobile Security Exception

msr*_*shp 5 jquery-mobile windows-8 cordova

我使用phonegap 2.9.0创建了一个Windows 8项目,然后尝试在其中使用JQuery移动库.但是我得到以下安全异常.知道如何解决这个问题吗?

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.
Run Code Online (Sandbox Code Playgroud)

She*_*net 2

我刚刚遇到了同样的问题。看来问题的关键在于,当您从字符串创建元素(例如使用 .html() 方法)时,WinJS 安全模型将不允许 JQuery dom 操作。

有关详细信息,请参阅以下内容: http://blogs.msdn.com/b/windowsappdev/archive/2013/04/01/windows-store-app-support-in-jquery-version-2-0.aspx

http://net.tutsplus.com/tutorials/javascript-ajax/building-windows-store-applications-with-jquery-2-0/

总之,聪明的人们在 JQuery 2.0 中对此进行了修复。

因此,我将考虑使用 JQuery 2.0,但它可以与 JQuery Mobile 一起使用吗?我还没有确定这一点,所以我可能会考虑完全构建和附加 dom 元素,而不是使用 .html() 方法。

但请注意,我尚未尝试过任何这些方法,因此无法保证它们的有效性。