The PageHTML plugin allows you to add custom HTML content to every survey page, whereas the HTML element adds HTML to a single page. This can be useful for adding instructions, images, or any other HTML elements to enhance the survey experience.
const customContent = new PageHTML({ content: '<h2>Welcome to our survey!</h2><p>Please answer the following questions honestly.</p>', position: 'top'});survey.addPlugin(customContent);
Here’s an example of how to create a PageHTML plugin with custom styling:
Copy
const welcomeMessage = new PageHTML({ content: ` <div class="welcome-message"> <h2>Welcome to Our Customer Satisfaction Survey</h2> <p>Your feedback is important to us. This survey will take approximately 5 minutes to complete.</p> <ul> <li>All responses are anonymous</li> <li>Please answer all questions honestly</li> <li>If you have any issues, please contact our support team</li> </ul> </div> `, position: 'top', styles: { '.welcome-message': { backgroundColor: '#f0f8ff', padding: '20px', borderRadius: '8px', marginBottom: '20px', boxShadow: '0 2px 4px rgba(0,0,0,0.1)' }, '.welcome-message h2': { color: '#2c3e50', marginBottom: '10px' }, '.welcome-message p': { color: '#34495e', marginBottom: '15px' }, '.welcome-message ul': { paddingLeft: '20px' }, '.welcome-message li': { marginBottom: '5px' } }});survey.addPlugin(welcomeMessage);// Later, if you need to update the content:welcomeMessage.updateContent(` <div class="welcome-message"> <h2>Thank You for Completing Our Survey</h2> <p>Your responses have been recorded. We appreciate your time and feedback.</p> </div>`);