Linking to another html page in google apps script does not seem to work -


i have tried answer provided linking html page in google apps script, not go page my1, blank screen. in fact, tried expand adding third page, my3 , having 2 buttons on each page...

example:

my1.html has buttons "my2" & "my3"

my2.html has buttons "my1" & "my3"

my3.html has buttons "my1" & "my2"

from my1, can go either my2 or my3, either my2 or my3, pressing button, blank screen , when refreshed, end @ my1...

thank you.

code.gs

/**  * url google apps script running webapp.  */ function getscripturl() {  var url = scriptapp.getservice().geturl();  return url; }  /**  * "home page", or requested page.  * expects 'page' parameter in querystring.  *  * @param {event} e event passed doget, querystring  * @returns {string/html} html served  */ function doget(e) {   logger.log( utilities.jsonstringify(e) );   if (!e.parameter.page) {     // when no specific page requested, return "home page"     return htmlservice.createtemplatefromfile('my1').evaluate();   }   // else, use page parameter pick html file script   return htmlservice.createtemplatefromfile(e.parameter['page']).evaluate(); } 

my1.html

<!doctype html> <html>   <body>     <h1>source = my1.html</h1>     <?var url = getscripturl();?><a href='<?=url?>?page=my2.html'> <input type='button' name='button' value='my2.html'></a>     <?var url = getscripturl();?><a href='<?=url?>?page=my3.html'> <input type='button' name='button' value='my3.html'></a>   </body> </html> 

my2.html

<!doctype html> <html>   <body>     <h1>source = my2.html</h1>     <?var url = getscripturl();?><a href='<?=url?>?page=my1'> <input type='button' name='button' value='my1.html'></a>     <?var url = getscripturl();?><a href='<?=url?>?page=my3'> <input type='button' name='button' value='my3.html'></a>   </body> </html> 

my3.html

<!doctype html> <html>   <body>     <h1>source = my3.html</h1>     <?var url = getscripturl();?><a href='<?=url?>?page=my1'> <input type='button' name='button' value='my1.html'></a>     <?var url = getscripturl();?><a href='<?=url?>?page=my2'> <input type='button' name='button' value='my2.html'></a>   </body> </html> 

set sandbox mode iframe:

function doget(e) {   //logger.log( utilities.jsonstringify(e) );   logger.log(e.parameter.page);   var pgtoload = e.parameter.page;    if (!e.parameter.page) {     logger.log('!e.parameter.page')     // when no specific page requested, return "home page"     return htmlservice.createtemplatefromfile('my1').evaluate()        .setsandboxmode(htmlservice.sandboxmode.iframe);   }   logger.log('there page');   // else, use page parameter pick html file script   return htmlservice.createtemplatefromfile(pgtoload).evaluate()     .setsandboxmode(htmlservice.sandboxmode.iframe); } 

add:

<head>   <base target="_top"> </head> 

to pages, , work.

my1.html

<!doctype html> <html>   <head>     <base target="_top">   </head>   <body>     <h1>source = my1.html</h1>     <?var url = getscripturl();?><a href='<?=url?>?page=my2.html'> <input type='button' name='button' value='my2.html'></a>     <?var url = getscripturl();?><a href='<?=url?>?page=my3.html'> <input type='button' name='button' value='my3.html'></a>   </body> </html> 

Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -