简体   繁体   English

我可以从Google Apps脚本代码文件的侧边栏中获取当前HTML吗?

[英]Can I get the current HTML from a sidebar in a Google Apps Script code file?

I writing a Google Apps Script (Sheet Add-on), and I'd like to get the HTML of the currently displayed sidebar back to the server-side script. 我编写了一个Google Apps脚本(Sheet附加组件),我想将当前显示的侧边栏的HTML返回到服务器端脚本。 The reason is that I'm making a template-based system where the HTML of the side bar may have come from a range of possible templates, but all of the templates have the same callback function back to the server to make writing them easier. 原因是我正在制作一个基于模板的系统,其中侧栏的HTML可能来自一系列可能的模板,但是所有模板都具有相同的回调函数,可以使它们返回服务器,从而简化了编写过程。 So the common callback function on the server-side needs to be able to determine what HTML it was called from. 因此,服务器端的通用回调函数必须能够确定从哪个HTML调用。

Is there any way to do this? 有什么办法吗?

Do you really need all the HTML? 您真的需要所有HTML吗? Or just enough information to know which template was used? 或者只是足够的信息来知道使用了哪个模板? When you load the templates initially you can store some metadata about what template was used in, for instance, an HTML element. 最初加载模板时,您可以存储一些有关所用模板的元数据,例如HTML元素。 Something like <...data-template-type="template 7"> 类似于<...data-template-type="template 7">

When you make the call to the server, grab that information from the HTML element and provide it as an argument. 调用服务器时,请从HTML元素中获取该信息并将其作为参数提供。

Hope I understood the question and what you're trying to do. 希望我理解这个问题以及您要做什么。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我可以通过与侧边栏中的按钮关联的 function 操作基于 html 的 Google Apps 脚本侧边栏中的文本框吗? - Can I manipulate a Textbox in an html based Google Apps Script Sidebar through a function associated to a button in that Sidebar? 如何在Google Apps脚本中获取“this”文件的当前实例? - How do I get the current instance of “this” file in Google Apps Script? 如何将变量从HTML脚本文件传递到Google Apps脚本中的javascript函数? - How can I pass a variable from an HTML script file to a javascript function in google apps script? 将数组值从Google表格添加到HTML边栏(Google Apps脚本) - Add array values to HTML sidebar from Google Sheet (Google Apps Script) Google Apps脚本从Date()获取当前月份 - Google Apps Script get current month from Date() 如何在Google Apps脚本中将数组显示到HTML侧边栏 - How to display an array to a HTML sidebar in Google apps script 如何将数组(Google Apps脚本)返回到HTML边栏? - How to return an array (Google apps script) to a HTML sidebar? 如何使用 gs 文件中的变量作为 Google Apps 脚本中 HTML 文件的输入值? - How can I use the variable in the gs file as the input value in the HTML file in Google Apps script? 如何从另一个HTML文件中的一个HTML Apps脚本文件获取JSON数据? - How do I get JSON data from one HTML Apps Script file in another HTML file? 如何使用内置的 HTML 侧边栏浏览器执行应用程序脚本 Function? - How can I execute an Apps Script Function using a built in HTML sidebar browser?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM