My task is to inject a custom JS function to an HTML code where we cannot edit buttons and HTML it self, just inject some custom HTML code through GUI. What I have in the code:
<input class="ContinueAsAGuest LinkButton" name="submitForm" type="submit" value="Continue as a guest >" />
What I need:
<input class="ContinueAsAGuest LinkButton" name="submitForm" type="submit" value="Continue as a guest >" onclick = "captureOutcome()" />
I wanted to use DOM, but I failed, I stay get the original code. This what I have:
var guest = getElementsByClassName("ContinueAsAGuest LinkButton");
guest.onclick = "captureOutcome()";
function captureOutcome(
{'eventName':'event registration','eventAction':'start' }
);
I am guessing what I miss is to add the actual onclick
to the original code.
Am I on the right path?