Surveys and Outreach

Get Involved. Join the Conversation.

Topic

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

    Hello,

    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

    Version:
    18B
    Code Snippet:

    Comment

     

    • 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?

      Thanks

    • 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:

      https://documentation.custhelp.com/euf/assets/devdocs/cloud18b/olh/MarketingAndFeedback/topicrefs/c_Using_dynamic_content_ai1303418.html?

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

      BR, Rob