Google apps script 在Google应用程序脚本中执行HtmlOutput代码,无需打开边栏
编辑:使用结束操作元素,而不是在侧边栏中创建它们 是否可以在后台页面中创建executeGoogle apps script 在Google应用程序脚本中执行HtmlOutput代码,无需打开边栏,google-apps-script,google-docs,Google Apps Script,Google Docs,编辑:使用结束操作元素,而不是在侧边栏中创建它们 是否可以在后台页面中创建executehtmlOutput,或者在不向用户显示任何内容的情况下创建 示例代码如下: plugin.gs function onOpen(e) { DocumentApp.getUi().createAddonMenu() .addItem('Start', 'run') .addToUi(); } /** * Opens a sidebar in the document
htmlOutput
,或者在不向用户显示任何内容的情况下创建
示例代码如下:
plugin.gs
function onOpen(e) {
DocumentApp.getUi().createAddonMenu()
.addItem('Start', 'run')
.addToUi();
}
/**
* Opens a sidebar in the document containing the add-on's user interface.
*/
function run() {
var ui = HtmlService.createTemplateFromFile('sidebar').evaluate()
.setTitle(constants.title);
DocumentApp.getUi().showSidebar(ui);
}
sidebar.html
<html>
<head>
<script>
console.log("Hello world!");
</script>
</head>
</html>
log(“你好,世界!”);
这是可行的,但它会弹出侧边栏。如果我注释掉DocumentApp.getUi().showSidebar(ui)代码>,则永远不会创建或执行该页
上下文:我想运行一些需要使用基本API/DOM操作的脚本,如window
,document
,等等。这些脚本不会在服务器端gs
文件上运行。我希望这种情况不必打开侧栏。使用Logger.log(ui)。您可以使用该服务将数据加载到html输出,然后在电子邮件中使用它,而无需运行html页面。@lamblichus OP希望运行这些来获取html中的内容。document.getElementById(…).value
。基本上,他正在寻找一个html解析器,但具有脚本功能,比如或者我认为更好的方法是使用一个虚拟dom,比如。谢谢大家。“hanok考虑添加一个应答器一个记录器。日志(UI)。您可以使用该服务将数据加载到HTML输出中,然后将其用于HTMLBOST的电子邮件中,而不必运行HTML页面。@ LAMBLIGUS OP想要运行这些文件以获得HTML中的内容。<代码>文档。GETelEnMyByID(…)。基本上,他正在寻找一个html解析器,但具有脚本功能,比如或者我认为更好的方法是使用一个虚拟dom,比如。谢谢大家。