2016-09-06 101 views
0

我已經提出了類似的問題。我似乎無法得到onclick事件爲我開火。是否有某些人可以幫助我在這裏。該函數寫在代碼下面。使用this.ParentNode無法從HTML頁面調用Google腳本

<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"); 
} 

任何幫助深表感謝。

+0

嘗試用'this.target.parentNode'替換'this.parentNode' – dlopez

+0

感謝您的回覆。我仍然沒有得到任何東西 – KPM

+0

您是否收到任何幫助我們發現問題的錯誤消息? – dlopez

回答

0

我記得大約一年前我在這裏掙扎了很多。我在把頭髮撕掉幾個小時後纔開始工作,讓我分享我的一些代碼,這樣可能會有所幫助。

首先在你的頁面的<head></head>(假設你有一個結構良好的HTML頁面),你可以添加一個錯誤處理程序:

<script> 
    function onFailure(error) { 
    var div = document.getElementById('output'); 
    div.innerHTML = "ERROR: " + error.message; 
    } 
</script> 

那麼你<body>年底前加一個「輸出」分區:

<div id="output"></div> 

這應該輸出你不知道之前,當你點擊按鈕

終於來了一些錯誤是「oncli CK「我使用: onclick="google.script.run.withFailureHandler(onFailure).FUNCTIONNAME(this.parentNode)"

希望這有助於!