Universal Javascript app errors RRS feed

  • Question

  • I am making a relatively simple windows 10 app with html and JavaScript. I got almost everything working but when I try to load one of my pages I get lots of errors and my onclick event doesn t work anymore.

    DOM7011: The code on this page disabled back and forward caching. For more information

    HTML1506: Unexpected token.
    MainDishes.html (392,6)

    CSP14312: Resource violated directive script-src ms-appx: unsafe-eval in Host Defined Policy: inline script. Resource will be blocked.

    I am using an onclick event to go to the top of the page that no longer works. I know i can't have any inline script but i don't think i do. All my script is in a separate file. what do i do???

    This is the html that doesn't work. if you need more information just tell me.


    Saturday, September 26, 2015 6:32 PM


  • Hello Coeus89,

    I looked at the html page. the code below

      <a target="_self" href="/MainDishes/POLENTA.html" class="pageFetcher" onclick="goToTop()">
                    <img src="/MainDishes/Polenta.jpg" alt="Polenta">

    Did you try adding onclick event using JavaScript instead of the inline html? I Tested in UWP and inline onclick does not work Instead you can use getElementsByClassName function.

    	var elements = document.getElementsByClassName('pageFetcher');
    	for (var i = 0; i < elements.length; i++) {
    	elements[i].addEventListener('click', goToTop, false);

    Or Alternatively you can follow Prashant's suggestion here to make it work with your current HTML and inline JavaScript


    Hope this helps.

    With Regards,

    Krunal Parekh

    Thanks MSDN Community Support Please remember to Mark as Answer the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Monday, September 28, 2015 5:55 AM