Skip to content

Instantly share code, notes, and snippets.

@stursby
Last active April 23, 2026 15:03
Show Gist options
  • Select an option

  • Save stursby/f484c0f98d78df41c64cda3edead7e86 to your computer and use it in GitHub Desktop.

Select an option

Save stursby/f484c0f98d78df41c64cda3edead7e86 to your computer and use it in GitHub Desktop.
Form submission event

After form submission (Vendor)

<form id="sweepsForm">
  <!-- form fields here -->
</form>

<script>
  const form = document.querySelector('#sweepsForm');

  form.addEventListener('submit', (event) => {
    window.parent.postMessage({
      name: 'sweepsFormSuccess'
    }, '*')
  });    
</script>

On microsite (Colle McVoy)

<script>
  window.addEventListener('message', (event) => {
    if (event.data.name === 'sweepsFormSuccess') {
      // show sweeps giveaway UI
    }
  });
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment