Windows 8 Phonegap 应用程序 JQuery 移动安全异常 [英] Windows 8 Phonegap Application JQuery Mobile Security Exception

查看:29
本文介绍了Windows 8 Phonegap 应用程序 JQuery 移动安全异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

在 ms-appx://c6a291ce-903f-47ab-b167-cb8378ffb051/www/libs/jquery.core/jquery-1.9.1.min.js 中的第 4 行第 7009 列抛出异常0x800c001c - JavaScript 运行时错误:无法添加动态内容.脚本试图注入可能不安全的动态内容或先前动态修改的元素.例如,使用innerHTML 属性添加脚本或格式错误的HTML 将生成此异常.使用 toStaticHTML 方法过滤动态内容,或使用 createElement 等方法显式创建元素和属性.有关详细信息,请参阅 http://go.microsoft.com/fwlink/?LinkID=247104.如果有针对此异常的处理程序,则程序可以安全地继续.

解决方案

我刚刚遇到了同样的问题.问题的关键似乎在于,当您从字符串创建元素时,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/

总而言之,聪明的人已经在 J​​Query 2.0 中解决了这个问题.

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

但请注意,我还没有尝试过这些方法中的任何一种,因此无法保证它们的有效性.

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.

解决方案

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

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

In summary the clever people have produced a fix to this in JQuery 2.0.

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 移动安全异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆