Search code examples
javascripthtmlgoogle-apps-scriptweb-applications

Malformed Html, function in onclick


I'm struggling to find workaround with GAS. This very simple, work perfectly fine in this snippet or in any html tool.

<a href="#" onclick=dummyFunc(foo)>OK</a>
<a href="#" onclick=dummyFunc("param")>not OK</a>

But google app script dont reconize the seconde line like valid html. If you put it in HtmlService.createHtmlOutput() or any other function that create html from the HtmlService it will raise Exception: Malformed HTML content.

EDIT

The only way I find to make it work is using:

<script>var param="param";</script>
<a href="#" onclick=dummyFunc(param)>OK</a>

Thank for you help. Have a great day.


Solution

  • Indeed, your html is not valid. Here's the right way :

    <a href="#" onclick="dummyFunc('param')">OK</a>