Search code examples
htmlgoogle-apps-scriptiframeweb-applicationswindow.open

Refreshing a page opened with window.location.replace or window.open(url,'_self') takes me to previous window


I have a published google web app that I am using as a splash screen. When I click a button on this screen it correctly takes me to the page (using either of the methods below). When I refresh that page, however, it returns me to the splash screen instead of keeping me on the newly opened screen, as I'd like it to do. I thought window.location.replace would correct this, but it is still doing it.

I have tried window.open(myurl,'_self') and window.location.replace(myurl) and it keeps happening. If I create a new tab with just window.open(myurl) and I refresh that, it keeps me on the correct page. I would prefer to not have the user open a bunch of tabs for this to work correctly. Is there something I am missing to make this refresh to the page that was opened with the window command?


Solution

  • Since your app is loaded in a sandboxed iframe, you should use

    window.open(myurl,'_top')
    

    to load in the top frame