As you probably know, jQuery Mobile uses AJAX navigation to switch between pages. This creates a richer user experience but also causes some issues on the Windows platform(both metro and phone). Your page might contain some unsafe HTML which will cause the following error:
In the previous blog post I created a hack in jQuery with a MSApp.execUnsafeLocalfunction wrapper which allows adding dynamic content. Well this hack was highly volatile and probably incomplete. Luckily for you and me we have some smart guys at MSOpenTech which solved this problem for us. They created a "JavaScript Dynamic Content shim for Windows Store apps".
The shim basically wraps all unsafe properties and functions in a MSApp.execUnsafeLocalfunction call. This will prevent WinJS from throwing exceptions when you dynamically add unsafe HTML. Please take a look at their Github page for more information.
Hope this helps!
Unhandled exception at line 5472, column 5 in ms-appx://<app identifier>/www/js/jquery/jquery-2.0.2.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.
In the previous blog post I created a hack in jQuery with a MSApp.execUnsafeLocalfunction wrapper which allows adding dynamic content. Well this hack was highly volatile and probably incomplete. Luckily for you and me we have some smart guys at MSOpenTech which solved this problem for us. They created a "JavaScript Dynamic Content shim for Windows Store apps".
The shim basically wraps all unsafe properties and functions in a MSApp.execUnsafeLocalfunction call. This will prevent WinJS from throwing exceptions when you dynamically add unsafe HTML. Please take a look at their Github page for more information.
Hope this helps!
No comments:
Post a Comment