How to Open a Url Link from JavaScript Inside a Google Apps Script HTML Google Site Gadget

get current page url

You can get the url for a webapp via ScriptApp:

<a href="<?= ScriptApp.getService().getUrl() + "?item=xyz" ?>" >Item xyz link</a>

and you can get the url in sites via SitesApp:


although I don't think that's actually useful for what you seem to be describing since you can't add useful query parameters to it. Scripts run in iframes, so although you can use document.location on the client, it won't help you anyways. The URL is sanitized and the service id is stripped out.

how to open multiple url through code, we have a code but its for only one url

With you can open as many windows as you want

Sample to open two urls in two different windows:

function myFunction() {
var js = " \
<script> \'', '_blank', 'width=800, height=600'); \'', '_blank', 'width=800, height=600'); \; \
</script> \
var html = HtmlService.createHtmlOutput(js)
SpreadsheetApp.getUi().showModalDialog(html, 'Now loading.');

Related Topics

Leave a reply