Mauricio Luis Lorenzi
Mauricio Luis Lorenzi

Reputation: 23

How to go to another page when i click on a link all inside of an iframe that is a google script web app?

I have a google apps script that has a lot of pages, and to go to these pages, inside the app, I use a button inside a link like this

<a href="scriptUrl?page=pageParameter"> <input type="button" value="next page"/> </a> 

When I put this script in an iframe and click to go to another page, the browser doesn't load the page inside the iframe, it loads the url in the full page.

What can I do to solve this?

thats my code

Upvotes: 2

Views: 656

Answers (1)

Douglas Gaskell
Douglas Gaskell

Reputation: 10030

You need to add a target attribute to your <a>.

To open the link in a new tab, do this:

<a href="scriptUrl?page=pageParameter" target="_blank"> <input type="button" value="next page"/></a>

This is what I currently am using in my Apps Script web apps.

NOTE: You cannot change the current page's URL due to restrictions that Google puts on the IFrame your app runs in. You can only change the IFrame's URL. This results in awkward navigation behavior if you want to make something like a multi-page static site.

If you want multi-page navigation in your Apps Script Web App, you need to design it like a single-page-application and re-render the HTML without changing the URL or reloading the page. You can accomplish this with frameworks like AngularJS.

Upvotes: 2

Related Questions