2013-08-26 55 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組件。 –

相關問題