none
[UWP][HTML] JavaScript runtime error: 'Windows' is not defined

    Question

  • Hi,

    I'm developing a game in visual studio and winjs project to display microsoft ads on app.

    When run i got error below,

    Resource violated directive 'script-src ms-appx: data: 'unsafe-eval''

    To avoid this i changed source like below,

    ................................................................

    Or...alternately...here's what you could do without splitting the default.html or the iframe concept...

    1.) In your package.appxmanifest file, point your StartPage to: ms-appx-web:///index.html.

    2.) Doing this will cause your app package to point to the start page in the "web" context

    3.) Then add the following lines to the manifest file:

    <uap:ApplicationContentUriRules>
      <uap:Rule Type="include" Match ="ms-appx-web:///" WindowsRuntimeAccess="allowForWebOnly"/>
    </uap:ApplicationContentUriRules>

    If you don't do this, then you can't reference the Windows Runtime (default.js references Windows.ApplicationModel.Activation)

    And then you should be able to load the map successfully from the web context....

    .....................................................................................................................................

    I could only add "package.appxmanifest file, point your StartPage to: ms-appx-web:///index.html.'

    BUT i could not add 

    <uap:ApplicationContentUriRules>
      <uap:Rule Type="include" Match ="ms-appx-web:///" WindowsRuntimeAccess="allowForWebOnly"/>
    </uap:ApplicationContentUriRules>

    to app manifest file as There is no appmanifest file in WinJs projects. (Project ->New Item)

    Because of this i'm getting errors.....

    Full Source Code -

    https://www.amilajayathissa.com/myftp/Sudoku.zip

    please check source code and correct it and please reupload so i can download it.

    Please help...

    Thanks.

    Wednesday, November 7, 2018 3:34 PM

All replies

  • Hi,

    Well, I've looked at your project after downloaded it. There is a package manifest file in your project already and you could add the Content URIs directly.

    Like this:

    Best regards,

    Roy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, November 8, 2018 2:30 AM
    Moderator
  • I added Content URIs  in appmanifest file but after that i got another javascipt error in sudoku.js

    The only way is make start page as index.html in app manifest (see screenshot).

    when i do that i get below errors,

    CSP14321: Resource violated directive 'script-src ms-appx: 'unsafe-eval' blob:' in Host Defined Policy: inline script, in ms-appx://31537606-d9a5-4c9a-8522-37f615774d2d/index.html at line 123 column 55. Resource will be blocked.

    that make the game function wrongly.

    I need to correct this error,

    CSP14321: Resource violated directive 'script-src ms-appx: 'unsafe-eval' blob:' in Host Defined Policy: inline script, in ms-appx://31537606-d9a5-4c9a-8522-37f615774d2d/index.html at line 123 column 55. Resource will be blocked. 

    That will make game function properly


    • Edited by coolaij12 Thursday, November 8, 2018 1:37 PM
    Thursday, November 8, 2018 1:36 PM
  • Hi,

    Well, this problem might be related to CSP(Content Security Policy). You could just change the meta tag in the index html file.

    Like this:

    <meta http-equiv="Content-Security-Policy" content="default-src 'self';">
    There are also many tutorials on the internet that you could open your search engine and search for Content Security Policy (CSP).


    Best regards,

    Roy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, November 9, 2018 4:26 AM
    Moderator
  • Hi,

    I added your code but still following warnings shown and game stopped and not functioning. I think it's blocked.

    can you check with my source code and resolve it. I can't solve it, i checked internet but still i couldn't solve it.

    Full Source Code -

    https://www.amilajayathissa.com/myftp/Sudoku.zip

    .............................................................................................................................................................

    CSP14312: Resource violated directive 'default-src 'self'' in meta http-equiv="Content-Security-Policy">: inline style. Resource will be blocked.
    The method Windows.UI.ApplicationSettings.ISettingsPaneStatics.getForCurrentView has been deprecated. SettingsPane is deprecated and might not work on all platforms. For more info, see MSDN.
    eval code (2) (1,7)
    The event Windows.UI.ApplicationSettings.ISettingsPane.add_CommandsRequested has been deprecated. SettingsPane is deprecated and might not work on all platforms. For more info, see MSDN.
    eval code (3) (1,7)
    CSP14321: Resource violated directive 'default-src 'self'' in meta http-equiv="Content-Security-Policy">: inline style, in ms-appx://31537606-d9a5-4c9a-8522-37f615774d2d/index.html at line 30 column 26. Resource will be blocked.
    CSP14321: Resource violated directive 'script-src ms-appx: 'unsafe-eval' blob:' in Host Defined Policy: inline script, in ms-appx://31537606-d9a5-4c9a-8522-37f615774d2d/index.html at line 29 column 32. Resource will be blocked.
    CSP14321: Resource violated directive 'script-src ms-appx: 'unsafe-eval' blob:' in Host Defined Policy: inline script, in ms-appx://31537606-d9a5-4c9a-8522-37f615774d2d/index.html at line 29 column 14. Resource will be blocked.
    CSP14321: Resource violated directive 'script-src ms-appx: 'unsafe-eval' blob:' in Host Defined Policy: inline script, in ms-appx://31537606-d9a5-4c9a-8522-37f615774d2d/index.html at line 66 column 85. Resource will be blocked.
    CSP14321: Resource violated directive 'script-src ms-appx: 'unsafe-eval' blob:' in Host Defined Policy: inline script, in ms-appx://31537606-d9a5-4c9a-8522-37f615774d2d/index.html at line 67 column 88. Resource will be blocked.
    CSP14321: Resource violated directive 'script-src ms-appx: 'unsafe-eval' blob:' in Host Defined Policy: inline script, in ms-appx://31537606-d9a5-4c9a-8522-37f615774d2d/index.html at line 68 column 89. Resource will be blocked.
    CSP14321: Resource violated directive 'script-src ms-appx: 'unsafe-eval' blob:' in Host Defined Policy: inline script, in ms-appx://31537606-d9a5-4c9a-8522-37f615774d2d/index.html at line 73 column 81. Resource will be blocked.
    CSP14321: Resource violated directive 'script-src ms-appx: 'unsafe-eval' blob:' in Host Defined Policy: inline script, in ms-appx://31537606-d9a5-4c9a-8522-37f615774d2d/index.html at line 74 column 78. Resource will be blocked.
    CSP14321: Resource violated directive 'script-src ms-appx: 'unsafe-eval' blob:' in Host Defined Policy: inline script, in ms-appx://31537606-d9a5-4c9a-8522-37f615774d2d/index.html at line 75 column 69. Resource will be blocked.
    CSP14321: Resource violated directive 'script-src ms-appx: 'unsafe-eval' blob:' in Host Defined Policy: inline script, in ms-appx://31537606-d9a5-4c9a-8522-37f615774d2d/index.html at line 93 column 29. Resource will be blocked.
    CSP14321: Resource violated directive 'script-src ms-appx: 'unsafe-eval' blob:' in Host Defined Policy: inline script, in ms-appx://31537606-d9a5-4c9a-8522-37f615774d2d/index.html at line 94 column 29. Resource will be blocked.
    CSP14321: Resource violated directive 'script-src ms-appx: 'unsafe-eval' blob:' in Host Defined Policy: inline script, in ms-appx://31537606-d9a5-4c9a-8522-37f615774d2d/index.html at line 95 column 29. Resource will be blocked.
    CSP14321: Resource violated directive 'script-src ms-appx: 'unsafe-eval' blob:' in Host Defined Policy: inline script, in ms-appx://31537606-d9a5-4c9a-8522-37f615774d2d/index.html at line 96 column 29. Resource will be blocked.
    CSP14321: Resource violated directive 'script-src ms-appx: 'unsafe-eval' blob:' in Host Defined Policy: inline script, in ms-appx://31537606-d9a5-4c9a-8522-37f615774d2d/index.html at line 103 column 29. Resource will be blocked.
    CSP14321: Resource violated directive 'script-src ms-appx: 'unsafe-eval' blob:' in Host Defined Policy: inline script, in ms-appx://31537606-d9a5-4c9a-8522-37f615774d2d/index.html at line 104 column 41. Resource will be blocked.
    CSP14321: Resource violated directive 'script-src ms-appx: 'unsafe-eval' blob:' in Host Defined Policy: inline script, in ms-appx://31537606-d9a5-4c9a-8522-37f615774d2d/index.html at line 124 column 55. Resource will be blocked.
    CSP14321: Resource violated directive 'script-src ms-appx: 'unsafe-eval' blob:' in Host Defined Policy: inline script, in ms-appx://31537606-d9a5-4c9a-8522-37f615774d2d/index.html at line 125 column 55. Resource will be blocked.
    CSP14312: Resource violated directive 'default-src 'self'' in meta http-equiv="Content-Security-Policy">: inline style. Resource will be blocked.
    CSP14312: Resource violated directive 'default-src 'self'' in meta http-equiv="Content-Security-Policy">: inline style. Resource will be blocked.
    CSP14312: Resource violated directive 'default-src 'self'' in meta http-equiv="Content-Security-Policy">: inline style. Resource will be blocked.
    CSP14312: Resource violated directive 'default-src 'self'' in meta http-equiv="Content-Security-Policy">: inline style. Resource will be blocked.
    The method Windows.UI.ApplicationSettings.ISettingsPaneStatics.getForCurrentView has been deprecated. SettingsPane is deprecated and might not work on all platforms. For more info, see MSDN.
    eval code (3) (1,7)
    The event Windows.UI.ApplicationSettings.ISettingsPane.add_CommandsRequested has been deprecated. SettingsPane is deprecated and might not work on all platforms. For more info, see MSDN.
    eval code (4) (1,7)
    CSP14321: Resource violated directive 'default-src 'self'' in meta http-equiv="Content-Security-Policy">: inline style, in ms-appx://31537606-d9a5-4c9a-8522-37f615774d2d/index.html at line 30 column 26. Resource will be blocked.
    CSP14321: Resource violated directive 'script-src ms-appx: 'unsafe-eval' blob:' in Host Defined Policy: inline script, in ms-appx://31537606-d9a5-4c9a-8522-37f615774d2d/index.html at line 29 column 32. Resource will be blocked.
    CSP14321: Resource violated directive 'script-src ms-appx: 'unsafe-eval' blob:' in Host Defined Policy: inline script, in ms-appx://31537606-d9a5-4c9a-8522-37f615774d2d/index.html at line 29 column 14. Resource will be blocked.
    CSP14321: Resource violated directive 'script-src ms-appx: 'unsafe-eval' blob:' in Host Defined Policy: inline script, in ms-appx://31537606-d9a5-4c9a-8522-37f615774d2d/index.html at line 66 column 85. Resource will be blocked.
    CSP14321: Resource violated directive 'script-src ms-appx: 'unsafe-eval' blob:' in Host Defined Policy: inline script, in ms-appx://31537606-d9a5-4c9a-8522-37f615774d2d/index.html at line 67 column 88. Resource will be blocked.
    CSP14321: Resource violated directive 'script-src ms-appx: 'unsafe-eval' blob:' in Host Defined Policy: inline script, in ms-appx://31537606-d9a5-4c9a-8522-37f615774d2d/index.html at line 68 column 89. Resource will be blocked.
    CSP14321: Resource violated directive 'script-src ms-appx: 'unsafe-eval' blob:' in Host Defined Policy: inline script, in ms-appx://31537606-d9a5-4c9a-8522-37f615774d2d/index.html at line 73 column 81. Resource will be blocked.
    CSP14321: Resource violated directive 'script-src ms-appx: 'unsafe-eval' blob:' in Host Defined Policy: inline script, in ms-appx://31537606-d9a5-4c9a-8522-37f615774d2d/index.html at line 74 column 78. Resource will be blocked.
    CSP14321: Resource violated directive 'script-src ms-appx: 'unsafe-eval' blob:' in Host Defined Policy: inline script, in ms-appx://31537606-d9a5-4c9a-8522-37f615774d2d/index.html at line 75 column 69. Resource will be blocked.
    CSP14321: Resource violated directive 'script-src ms-appx: 'unsafe-eval' blob:' in Host Defined Policy: inline script, in ms-appx://31537606-d9a5-4c9a-8522-37f615774d2d/index.html at line 93 column 29. Resource will be blocked.
    CSP14321: Resource violated directive 'script-src ms-appx: 'unsafe-eval' blob:' in Host Defined Policy: inline script, in ms-appx://31537606-d9a5-4c9a-8522-37f615774d2d/index.html at line 94 column 29. Resource will be blocked.
    CSP14321: Resource violated directive 'script-src ms-appx: 'unsafe-eval' blob:' in Host Defined Policy: inline script, in ms-appx://31537606-d9a5-4c9a-8522-37f615774d2d/index.html at line 95 column 29. Resource will be blocked.
    CSP14321: Resource violated directive 'script-src ms-appx: 'unsafe-eval' blob:' in Host Defined Policy: inline script, in ms-appx://31537606-d9a5-4c9a-8522-37f615774d2d/index.html at line 96 column 29. Resource will be blocked.
    CSP14321: Resource violated directive 'script-src ms-appx: 'unsafe-eval' blob:' in Host Defined Policy: inline script, in ms-appx://31537606-d9a5-4c9a-8522-37f615774d2d/index.html at line 103 column 29. Resource will be blocked.
    CSP14321: Resource violated directive 'script-src ms-appx: 'unsafe-eval' blob:' in Host Defined Policy: inline script, in ms-appx://31537606-d9a5-4c9a-8522-37f615774d2d/index.html at line 104 column 41. Resource will be blocked.
    CSP14321: Resource violated directive 'script-src ms-appx: 'unsafe-eval' blob:' in Host Defined Policy: inline script, in ms-appx://31537606-d9a5-4c9a-8522-37f615774d2d/index.html at line 124 column 55. Resource will be blocked.
    CSP14321: Resource violated directive 'script-src ms-appx: 'unsafe-eval' blob:' in Host Defined Policy: inline script, in ms-appx://31537606-d9a5-4c9a-8522-37f615774d2d/index.html at line 125 column 55. Resource will be blocked.
    CSP14312: Resource violated directive 'default-src 'self'' in meta http-equiv="Content-Security-Policy">: inline style. Resource will be blocked.
    CSP14312: Resource violated directive 'default-src 'self'' in meta http-equiv="Content-Security-Policy">: inline style. Resource will be blocked.
    CSP14312: Resource violated directive 'default-src 'self'' in meta http-equiv="Content-Security-Policy">: inline style. Resource will be blocked.


    Friday, November 9, 2018 1:03 PM
  • I corrected the issue. thanks.
    Monday, November 12, 2018 2:58 PM
  • Hi,

    Glad to hear that you have solved the problem. Having a nice day!

    Best regards,

    Roy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, November 13, 2018 7:05 AM
    Moderator