Javascript 如何从客户端运行此工作

Javascript 如何从客户端运行此工作,javascript,google-apps-script,web-applications,Javascript,Google Apps Script,Web Applications,我已经用尽了我可能尝试的所有可能的排列方式,比如将所有的.js代码移到html中,但是函数不会从文档的侧栏运行,在每次运行中——单击其中任何一个按钮——我必须返回脚本的编辑器来运行侧栏。我在html中嵌入的函数脚本是: 函数检查(){ google.script.run.results_run(); } 函数Clear(){ google.script.run.results_clear(); } 检查 清晰的亮点 从onclick=“javascript:Check();”和onclic

我已经用尽了我可能尝试的所有可能的排列方式,比如将所有的.js代码移到html中,但是函数不会从文档的侧栏运行,在每次运行中——单击其中任何一个按钮——我必须返回脚本的编辑器来运行侧栏。我在html中嵌入的函数脚本是:

函数检查(){
google.script.run.results_run();
}
函数Clear(){
google.script.run.results_clear();
}
检查
清晰的亮点

  • onclick=“javascript:Check();”
    onclick=“javascript:Clear();”
    中删除
    javascript:
    ,因为不需要它。最好使用事件侦听器而不是内联JavaScript
  • 当使用
    google.script.run
    时,使用
    和SuccessHandler
    以及
    和FailureHandler
  • 查看脚本执行页面,可能记录了服务器端错误

  • 尝试禁用新的运行时(Chrome V8)

  • 资源

    相关的


    您如何调用这些函数?(请包括a)此外,请按照中的建议,添加有关您的搜索/研究工作的更多详细信息(可以很简短,但应该更具描述性)。请回答问题。``检查清除突出显示函数检查(){google.script.run.results_run();}函数Clear(){google.script.run.results_Clear();}``从我的HTMLTanks Ruben开始,我对这一点不熟悉。
    google.script.run.withFailureHandler(alert.results_run()
    
    function Check() {
      google.script.run
      .withSuccessHandler(function(){
        // if needed do something  when the server side function runs succesfully
      })
      .withFailureHandler(function(error){
        // if an error occurss on server side log the error into the console
        console.error(error.message,error.stack);
        
      }).results_run();
    }
    
    function Clear() {
      google.script.run
      .withSuccessHandler(function(){
        // if needed do something  when the server side function runs succesfully
      })
      .withFailureHandler(function(error){
        // if an error occurss on server side log the error into the console
        console.error(error.message,error.stack);
        
      }).results_clear();
    }