Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
google apps script to open a new website in a new window
function openTab() {
var selection = SpreadsheetApp.getActiveSheet().getActiveCell().getValue();
var html = "<script>window.open('" + selection + "');google.script.host.close();</script>";
var userInterface = HtmlService.createHtmlOutput(html);
SpreadsheetApp.getUi().showModalDialog(userInterface, 'Open Tab');
}
@paul-kline

This comment has been minimized.

Copy link

paul-kline commented Apr 11, 2018

nice nice.

@urwa

This comment has been minimized.

Copy link

urwa commented Jul 30, 2018

Awesome!

@stndstn

This comment has been minimized.

Copy link

stndstn commented Oct 17, 2018

Thanks

@raulsananes

This comment has been minimized.

Copy link

raulsananes commented Apr 5, 2019

Awesome! Worked perfectly.

@shivamragnar

This comment has been minimized.

Copy link

shivamragnar commented Mar 30, 2020

What if Spreadsheet is not the use case, suppose you have link for a Google Drive file and then you have to open that link in a new tab or window?

@mariodac

This comment has been minimized.

Copy link

mariodac commented Apr 10, 2020

Only works with google chrome?

@alexandreb06800

This comment has been minimized.

Copy link

alexandreb06800 commented Apr 14, 2020

Hello, how to open 2 url at the same time? Please

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.