使用 google 脚本将页面(链接)放在侧边栏中

Place page(linked) in a sidebar using google script

您好,我想知道这是否可行,因为我已经在 google 脚本教程中完成了侧边栏示例 我在单击时将 link 放到了 google 网站使用 google 搜索 打开一个选项卡 我的问题是,是否可以单击并在边栏中进行 google 页面搜索,然后就在那里进行搜索?谢谢。

<!DOCTYPE html>
<html>
  <head>
    <base target="_top">
  </head>
  <body>
    Click <a href="https://www.google.com/" target="_blank">here</a> for a google search
    <input type="button" value="Ferme"
        onclick="google.script.host.close()" />
  </body>
</html>

此脚本将从输入框中获取搜索词组并打开一个包含结果的新选项卡:

<!DOCTYPE html>
<html>
  <head>
    <base target="_top">

    <script>
      function doSearch() {
        var searchFor = document.getElementById("txtSearchFor").value;

        window.open("https://www.google.com/search?q=" + searchFor);
      }
    </script>
  </head>
  <body>
    <H1>Sidebar</H1>

    <input type="text" id="txtSearchFor"/>
    <input type="button" value="Search" id="btnSearch" onclick="doSearch()"/>

  </body>
</html>

如果你想对结果做一些实际的事情,那么你应该考虑使用 google custom search api ,这有点复杂。