【问题标题】:Unable to set a input value on Google Forms using Javascript无法使用 Javascript 在 Google 表单上设置输入值
【发布时间】:2020-12-16 16:55:58
【问题描述】:

我正在尝试为谷歌表单制作一个自动填充扩展,但我无法更改输入/文本区域的值。这是 content.js 上的代码document.getElementsByClassName('quantumWizTextinputPapertextareaInput exportTextarea')[0].value = "Some Answer"This is what happens on google forms

如果我尝试提交它,我会收到一条错误消息,指出该问题是强制性的 The error

如果我在输入中键入或删除某些内容,那么它会识别文本并且我可以提交它。我真的希望有人能帮助我Here is the form link

【问题讨论】:

  • 您还需要为data-initial-value 属性设置值。
  • 还是不行

标签: javascript input google-chrome-extension textarea google-forms


【解决方案1】:

我使用execCommand 找到了解决此问题的方法。由于google表单使用jscontroller和jsaction进行动态js执行,所以仅仅设置值是不行的。

document.getElementsByClassName("quantumWizTextinputPapertextareaInput exportTextarea")[0].focus();
document.execCommand('insertText', false, 'Some Answer');

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-09-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-01-20
    • 1970-01-01
    相关资源
    最近更新 更多