Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not working with windows 8 apps when using jquery prior to version 2.0 #52

Open
grafxmike opened this issue Feb 27, 2014 · 1 comment
Open

Comments

@grafxmike
Copy link

This problem only occurs when using jquery versions prior to 2.0.

The following code will cause an error in windows 8 apps.

if ($('#css-ddslick').length <= 0 && options.embedCSS) {
    $(ddslickCSS).appendTo('head');
}

This is because the windows 8 app runtime tries to prevent injection of malicious code by dynamic html injection. However, there is a function which can fix this issue: MSApp.execUnsafeLocalFunction

Thus I suggest the following workaround.

if ($('#css-ddslick').length <= 0  && options.embedCSS) {
    // Special case for Windows 8 Apps
    if (typeof MSApp === 'undefined') {
        // Not windows 8
        $(ddslickCSS).appendTo('head');
    }
    else {
        // Windows 8
        MSApp.execUnsafeLocalFunction(function () {
            $(ddslickCSS).appendTo('head');
        });
    }
}
grafxmike added a commit to grafxmike/ddslick that referenced this issue Feb 27, 2014
@grafxmike grafxmike mentioned this issue Feb 27, 2014
@andreszs
Copy link

I can't belive I have to type MSApp.execUnsafeLocalFunction before thousands of append() and prepend() methods for my WP8 apps. This makes no sense at all, is there another solution please? Thanks..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants