LANG SELRCT

Apps Script Reference  (Create: Create new Spreadsheet | Create new Apps Script

Sunday, December 31, 2017

ボタンをクリックしたら新規ページを開く

HTML Serviceでこういうボタンを作る





クリックした時に指定したページを開くボタンの例です
下のindex.htmlの
window.open("https://www.google.co.jp/");
で開くページのURLを指定しています



コード.gs
function doGet() {
  return HtmlService.createHtmlOutputFromFile("index");
}
意訳
この機能がやること
指定したHTMLファイルを表示する




index.html
<!DOCTYPE html>
<html>
<body>
  <button id="bt">新規ウィンドを開く</button>
  <script>
    document.getElementById("bt").onclick = bt_clicked;

    function bt_clicked() {
      window.open("https://www.google.co.jp/");
    }
  </script>
</body>
</html>
意訳
これはHTML5文書です


ボタンを置く(idはbt)

idがbtの要素がクリックされたら

この機能がやること
指定したページを新規タブで開く







Latest post

Extracting data from Google Sheets with regular expressions

Introduction Regular expressions are a powerful tool that can be used to extract data from text.  In Google Sheets, regular expressions ca...