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:

SitesApp.getActivePage().getUrl()

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 window.open you can open as many windows as you want

Sample to open two urls in two different windows:

function myFunction() {
var js = " \
<script> \
window.open('https://stackoverflow.com/', '_blank', 'width=800, height=600'); \
window.open('https://www.wikipedia.org/', '_blank', 'width=800, height=600'); \
google.script.host.close(); \
</script> \
";
var html = HtmlService.createHtmlOutput(js)
.setHeight(10)
.setWidth(100);
SpreadsheetApp.getUi().showModalDialog(html, 'Now loading.');
}


Related Topics



Leave a reply



Submit