1
votes

Upon clicking on a link to a new page, nothing happens from the user's perspective. The console prints out the error which reads:

Unsafe JavaScript attempt to initiate navigation for frame with origin 'https://sites.google.com' from frame with URL 'https://n-frzjyfhgihna65vdvol2wbbsyjjlfhey2xruiny-0lu-script.googleusercontent.com/userCodeAppPanel'. The frame attempting navigation of the top-level window is sandboxed, but the flag of 'allow-top-navigation' or 'allow-top-navigation-by-user-activation' is not set.

I'm not sure how to interpret this. From what I've read, Google Sites has a security measure that prevents embedded webapps from navigating using the "_top" page. Navigating using "_blank" as my target works, but is not what I hope to accomplish. How do I overcome this error?

1
Please take time to read and practice the references in that question until you understand. See How to Ask and minimal reproducible example. I don't think I can dumb it down more. If there's a specific thing you don't understand, ask a new specific question(You can ask dumb question as long it is specific and you've done your homework, but I can't write a exhaustive 101 material from top to bottom in a Q/A site).TheMaster

1 Answers

0
votes

It would help to see your code but I think I know what you're referring to. I experienced the same issue and you can see how I've implemented it on my blog post here - https://script.gs/password-protected-web-app/ (I take a text input from the user and reload the page programatically)

This is what's needed on the Code.gs file:

function webAppURL(linkAddr) {
  var linkAddr = ScriptApp.getService().getUrl()
  return linkAddr
}

And on the webapp *.html page:

<script>
    function reload() {
        var linkAddr
        google.script.run.withSuccessHandler(function(value) {
            window.open(value, '_top');
        }).webAppURL(linkAddr);
    }
</script>

Hope this helps and feel free to ping here in case it doesn't.