1

I am making Windows 8 application (JavaScript) using jQuery. But Visual Studio is not letting me show or hide different elements (div, span etc..) and the following error message appears:

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.

I just wrote following code:

$(document).ready(function () {
    $('#names').fadeIn();
});
Sampson
  • 265,109
  • 74
  • 539
  • 565
mshahbazm
  • 611
  • 1
  • 11
  • 23

1 Answers1

3

The Windows 8 security model doesn't permit dynamic content being added to the DOM via innerHTML or similar functions. This unfortunately occurs a few times when you include jQuery into your page (during the setup of jQuery.support).

The only solution is to rewrite portions of jQuery (which can be annoying), or use a version of jQuery that has already been reconfigured with Windows 8 in mind such as jQuery for Windows 8, by appendTo.

In full disclosure, I was involved in this particular project.

Sampson
  • 265,109
  • 74
  • 539
  • 565