Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/457.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
无法使用Javascript在Google窗体上设置输入值_Javascript_Input_Google Chrome Extension_Textarea_Google Forms - Fatal编程技术网

无法使用Javascript在Google窗体上设置输入值

无法使用Javascript在Google窗体上设置输入值,javascript,input,google-chrome-extension,textarea,google-forms,Javascript,Input,Google Chrome Extension,Textarea,Google Forms,我正在尝试为google表单创建一个自动填充扩展,但我无法更改输入/文本区域值。这是content.jsdocument.getElementsByClassName('quantumwiztputpapertextareainput exportTextarea')[0]上的代码。value=“Some Answer” 如果我试图提交它,我会得到一个错误,说这个问题是强制性的 如果我在输入中键入或删除某些内容,那么它会识别文本,我可以提交它。我真希望有人能帮我我找到了一个解决方法,使用exe

我正在尝试为google表单创建一个自动填充扩展,但我无法更改输入/文本区域值。这是content.js
document.getElementsByClassName('quantumwiztputpapertextareainput exportTextarea')[0]上的代码。value=“Some Answer”

如果我试图提交它,我会得到一个错误,说这个问题是强制性的


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

我找到了一个解决方法,使用
execCommand
。由于GoogleForms使用jscontroller和jsaction使用动态js执行,因此仅设置值将无法正常工作

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

我使用
execCommand
找到了解决方法。由于GoogleForms使用jscontroller和jsaction使用动态js执行,因此仅设置值将无法正常工作

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

您还需要为
数据初始值
属性设置值。仍然不起作用您还需要为
数据初始值
属性设置值。仍然不起作用。但是仍然无法工作检查控制台是否有任何错误。我只能在浏览器控制台上模拟这个,它可以在你的谷歌表单上运行。谢谢。但是仍然无法工作检查控制台是否有任何错误。我只能在浏览器控制台上模拟它,它可以在你的谷歌表单上运行。