Surveys and Outreach

Get Involved. Join the Conversation.


    Robert North
    Survey Template body onload event
    Topic posted May 22, 2019 by Robert NorthRed Ribbon: 250+ Points 
    52 Views, 9 Comments
    Survey Template body onload event
    Survey Template body onload event


    I have a Survey Template with an onload event in the body tag. This event fires a piece of JavaScript.

    It works fine with proofing surveys, but doesn't work when these Surveys are set live.

    Does anyone know why this might occur?

    Thanks, Rob

    Code Snippet:



    • Justin

      what type of script is showsmiley()?

    • Robert North

      Hi Justin, it's JavaScript.

      Thanks, Rob

    • Justin

      im wondering it the recieving mail client might be blocking it 

    • Robert North

      Hi Justin,

      No, it's displayed in a Survey Page not the Invitation.

      I'm thinking there is some restriction with onload events in the survey pages.

      BR, Rob

    • Justin

      since surveys use the portal i wonder if you have to add the JS to the folder there

    • Robert North

      Yes, the JS is referenced from a CP location.


    • Tushar Gupta

      Hi Robert,

      Have you tried directly using the Javascript in the Survey Page?


    • Robert North

      Hello Justin/Tushar,

      Thank you for your input.

      I've fixed this issue by adding an event listener to the window onload event directly in the JavaScript like:

      window.addEventListener ?
      window.addEventListener("load", <function>, false) :
      window.attachEvent && window.attachEvent("onload", <function>);

      I believe the JavaScript events that can be added to html elements within Survey Pages must be restricted as per:

      But it was strange that the body onload event worked in survey proofing mode & not live.

      BR, Rob