不能使用this.ParentNode从HTML页面调用Google脚本
Cannot call Google script from HTML page using this.ParentNode
我也问过类似的问题。我似乎无法让onclick事件为我触发。有没有什么显而易见的东西能帮到我。函数写在下面的代码
<div id= "right_column">
<form>
<input type="button" name="enter_grades" id="enter_grades" value="Enter Grades for Selected Lessons"
onclick="google.script.run.withSuccessHandler(showMsgForLoginAttempt).generate_grades_for_lesson(this.parentNode)" />
</form>
</div>
这是gscript函数
function generate_grades_for_lesson(formObject) {
Browser.msgBox("Hello");
}
我记得大约一年前我为此挣扎了很久。经过几个小时的辛苦工作,我终于让它工作了,让我分享一些我的代码,也许它会有所帮助。
首先在您的页面的<head></head>
(假设您有一个格式良好的HTML页面),您可以添加一个错误处理程序:
<script>
function onFailure(error) {
var div = document.getElementById('output');
div.innerHTML = "ERROR: " + error.message;
}
</script>
然后在您的<body>
结束前添加一个"output"div:
<div id="output"></div>
当你点击
按钮时,这会输出一些你之前没有意识到的错误。最后是我使用的"onclick":onclick="google.script.run.withFailureHandler(onFailure).FUNCTIONNAME(this.parentNode)"
希望这对你有帮助!
相关文章:
- 授权客户端JS API调用Google'的具有现有访问令牌的gap库
- Clojudescript:调用Google Maps API的问题
- 是否可以调用Google API获取地图图像并将图像保存在某个位置
- 从 vb.net 程序调用 Google Chrome 窗口中的 JavaScript 函数
- 从javascript代码调用Google API
- 从Dojo 1.7+调用Google Analytics的正确语法是什么?
- 我想调用Google Plus回调函数时,点击Google Plus按钮
- 如何从jQuery中初始化调用Google Map中的函数?
- 有没有办法在google API URL之外调用google initMap回调函数
- 对服务帐户进行身份验证,以便使用JavaScript客户端库调用Google API
- 不能从AJAX调用Google Maps API返回坐标
- 远程服务.getdistancemmatrix永远不会被调用(google maps API)
- 从Javascript调用Google Chrome扩展
- 如何在Html中调用Google地图API Javascript的变量
- 不能使用this.ParentNode从HTML页面调用Google脚本
- 调用Google Drive API返回Invalid_grant OAuth2
- 使用JS的服务帐户调用Google bigquery
- 调用google.maps.geometry.spherical.computeDistanceOff是否会对我的API
- 什么时候应该调用Google Maps MarkerClusterer
- 在Ionic框架中调用Google API for Javascript(在Web上工作,而不是在Android上工作)