Code : Tout sélectionner
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 to pick an html file from the script
return HtmlService.createTemplateFromFile(e.parameter['page']).evaluate();
}
/**
* Get the URL for the Google Apps Script running as a WebApp.
*/
function getScriptUrl() {
var url = ScriptApp.getService().getUrl();
return url;
}
Code : Tout sélectionner
<!DOCTYPE html>
<html>
<head>
<base target=<b>"_top"</b>>
</head>
<body>
<h1>Occasional contract generator</h1>
<? var url = getScriptUrl();?>
<?= console.log(getScriptUrl()) ?>
<button onclick=<b>href</b>=<b>'<?=url?>?page=my2'</b>>Page 2</button>
</body>
</html>
Code : Tout sélectionner
<!DOCTYPE html>
<html>
<head>
<base target=<b>"_top"</b>>
</head>
<body>
<h1>Page 2</h1>
<?var url = getScriptUrl();?><a href=<b>'<?=url?>?page=my1'</b>>Link to page1</a>
</body>
</html>