如何获取Google Form的JS脚本? [英] How to get JS script of a Google form?

查看:51
本文介绍了如何获取Google Form的JS脚本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Google表单,我如何才能获得它的js脚本?

我单击脚本编辑器,但找不到对应的js。

我已经在Internet上搜索了,但没有预期的答案。

-- 更新日期:2017/08/20

假设我拥有一个如下所示的表单: Sample Form

如何获取此表单的相应Google脚本?

function myFunction() {
    // Create a new form, then add a checkbox question, a multiple choice question,
    // a page break, then a date question and a grid of questions.
    var form = FormApp.create('Sample Form');
    var sect1 = form.addSectionHeaderItem();
    var item = form.addCheckboxItem();
    item.setTitle('What condiments would you like on your hot dog?');
    item.setChoices([item.createChoice('Ketchup'), item.createChoice('Mustard'), item.createChoice('Relish')]);
    var item2 = form.addMultipleChoiceItem().setTitle('Do you prefer cats or dogs?');
    //    .setChoiceValues(['Cats','Dogs'])
    //    .showOtherOption(true);
    var sect2 = form.addSectionHeaderItem();
    form.addPageBreakItem().setTitle('Getting to know you');
    form.addDateItem().setTitle('When were you born?');
    var sect3 = form.addSectionHeaderItem();
    var break2 = form.addPageBreakItem().setTitle('Getting to know you 2');

    var choice1 = item2.createChoice('cat', FormApp.PageNavigationType.CONTINUE);
    var choice2 = item2.createChoice('dog', break2);
    item2.setChoices([choice1, choice2]);

    form.addGridItem().setTitle('Rate your interests').setRows(['Cars', 'Computers', 'Celebrities']).setColumns(['Boring', 'So-so', 'Interesting']);
    Logger.log('Published URL: ' + form.getPublishedUrl());
    Logger.log('Editor URL: ' + form.getEditUrl());
}

推荐答案

谷歌脚本编辑器是谷歌允许人们使他们的表单(以及许多其他谷歌服务)更加灵活和可定制的一种方式。你甚至可以使用谷歌脚本创建附加组件。但不存在针对每个表单的默认用户脚本这样的事情;所有表单都是从根本没有用户Google Script开始的,您可以通过编写一些新脚本来添加更多功能。

现在,如果您想获取该表单的Java脚本源代码,则可以使用Chrome中的开发人员工具(Windows中的F12键)并转到源代码,在那里您将看到Google用于表单的所有脚本:

如果您左键单击该表单并查看其源代码,您将看到更多的小脚本块,它们主要与Google表单拥有的数据相关:

<script>_docs_flag_initialData={ ....
<script>;this.gbar_={CONFIG:[[[0,"www.gstatic.com", ....
<script type="text/javascript">var FB_PUBLIC_LOAD_DATA_ = [null,[null, ....

这篇关于如何获取Google Form的JS脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆