2013-08-26 53 views
5

我创建了一个使用phonegap 2.9.0的Windows 8项目,然后尝试在其中使用JQuery移动库。但是我得到以下安全异常。任何想法如何解决这个问题?Windows 8 Phonegap应用程序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. 
+0

同样的问题问了一段时间后: http://stackoverflow.com/questions/14471362/javascript-runtime-error-unable-to-add-dynamic-content –

+0

不,这不是一回事。这是用户定义的JavaScript。这是来自JQuery Mobile库本身。 – msrameshp

+0

任何人都可以请你帮助我??我真的被困在这里:(。 – msrameshp

回答

2

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

请参阅下面的详细资料: 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()方法。

但请注意,我还没有尝试过任何这些方法,因此无法保证其有效性。

+0

感谢您的输入。我已经通过用JQuery 2.0替换JQuery 1.9.1来解决JQuery问题。但我仍然遇到与JQuery Mobile 1.3.2和1.4.0 alpha相同的问题你有什么想法可以解决这些问题吗? – msrameshp

+0

你有没有办法解决? – d0001

+0

当天晚些时候,我放弃了使用.html()并且通过append创建了我的DOM组件。 –

相关问题