From 1b94f23ab320f1c723b25a46a51484c122c85d66 Mon Sep 17 00:00:00 2001 From: "David A. Madore" Date: Mon, 1 Jan 2024 17:14:26 +0100 Subject: Call an onEarly() function as soon as is created. --- org/madore/damlengine/TodoDamlElement.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/org/madore/damlengine/TodoDamlElement.java b/org/madore/damlengine/TodoDamlElement.java index f5b4a7f..7cd94e3 100644 --- a/org/madore/damlengine/TodoDamlElement.java +++ b/org/madore/damlengine/TodoDamlElement.java @@ -58,7 +58,12 @@ public final class TodoDamlElement extends TodoDefaultElement { Element bodyNode = ctx.doc.createElementNS(DamlEngine.XHTML_NS, "body"); htmlNode.appendChild(bodyNode); htmlNode.appendChild(ctx.doc.createTextNode("\n")); - bodyNode.setAttributeNS(null, "onload", "onLoad()"); + bodyNode.setAttributeNS(null, "onload", "if (onLoad) { onLoad(); }"); + Element earlyScript = ctx.doc.createElementNS(DamlEngine.XHTML_NS, "script"); + earlyScript.setAttributeNS(null, "type", "text/javascript"); + earlyScript.appendChild(ctx.doc.createTextNode("if (onEarly) { onEarly(); }")); + bodyNode.appendChild(ctx.doc.createTextNode("\n")); + bodyNode.appendChild(earlyScript); ctx.gc.styleContent = new StringBuffer(); try { -- cgit v1.2.3