首页 > 解决方案 > Google Apps Script google.script.run html not working, script not launched

问题描述

I really hope you can help me with this! I do not understand why my html 'script' does not want to communicate with my 'code' as it was happening before.

This is the story. I have built a little application with Google Apps Script. I wanted to transfer this application to another Google user, therefore I shared the file, then I made a copy so I would result as the owner.

Into this application I have a an html form that is called, user click a button, and the text of the button will be transferred to some cells in the Gsheet.

So for the first account, where the application comes from, it still works fine. For the second account it does not, and I can not figure out why. Is it something connected to the user? Is it something wrong into the code? Is it connected to the new Apps Script runtime powered by V8 recently released?

Please help me, it is quite important to me.

function NewshowDialog()
{
 var title = "Please Select STOP Reason";
     var uiDialog = HtmlService.createHtmlOutputFromFile('NewDialoghtml_ENG').setSandboxMode(HtmlService.SandboxMode.NATIVE);}
  uiDialog.setWidth(630);
  uiDialog.setHeight(330);
  return SpreadsheetApp.getUi().showModalDialog(uiDialog,title);
}

function msgbox_success()
{SpreadsheetApp.getUi().alert("Success");}

function msgbox_error()
{SpreadsheetApp.getUi().alert("Fail");}

function WriteInBreakName(breakname)
{ //write value in cells into the Gsheet}
<!DOCTYPE html>
<html>
  <head>
   <base target="_top">
    <script>
    function onSuccess() {
    google.script.run.msgbox_success();
    }
    
    function onFailure() {
    google.script.run.msgbox_error();
    }
    
      function myFunctionBreak_eng()
        {
          var breakname = document.getElementById("buttonBreak_eng").value;
            google.script.run.withSuccessHandler(onSuccess).withFailureHandler(onFailure).WriteInBreakName(breakname);
          google.script.host.close();
        }
        
    window.closeDia = function()
        {
          google.script.host.close();
        };
    </script>
    
    <style>
    .BreakButton {
            box-shadow: 0px 1px 0px 0px #f0f7fa;
            background:linear-gradient(to bottom, #83d6f2 5%, #019ad2 100%);
            background-color:#83d6f2;
            border-radius:6px;
            border:1px solid #bcbcbc;
            display:inline-block;
            cursor:pointer;
            color:#222222;
            font-family:Arial;
            font-size:38px;
            font-weight:bold;
            padding:6px 24px;
            text-decoration:none;
            text-shadow:0px 1px 0px #cbe6ef;
            height:150px;
            width:200px;
        }
        .BreakButton:hover {
            background:linear-gradient(to bottom, #019ad2 5%, #83d6f2 100%);
            background-color:#019ad2;
        }
        .BreakButton:active {
            position:relative;
            top:4px;
        </style>
  </head>
  
  <body>
    <button class="BreakButton" type="button" id="buttonBreak_eng" value="Break" onclick="myFunctionBreak_eng()">Break</button>
   </body>
</html>
  

标签: javascripthtmlfunctiongoogle-apps-scriptweb-applications

解决方案


推荐阅读