How can I create shareable links for the pop-ups I created on Webflow, so that clicking on the links will open the pop-ups directly, without the need to click on the buttons?

TL;DR
  • Assign unique IDs to each pop-up and add custom JavaScript in the Webflow project settings to open pop-ups based on URL hashes. 
  • Create direct links using these IDs, validate by testing across devices and browsers after publishing the site.

Creating shareable links to directly open pop-ups on your Webflow site involves specific steps to modify your project settings and add custom code. By doing this, users can click on a link that directly opens a specific pop-up without needing to interact with any buttons on the page. Here's how you can achieve this:

1. Set Up Unique IDs for Pop-Ups

  • Assign a unique ID to each pop-up on your page. This ID will be used to create shareable links.
  • Go to your pop-up element in the designer, and add an ID in the element settings panel. Make sure each pop-up has a different ID.

2. Add Custom Code to Your Project

  • Go to Project Settings in Webflow.
  • Open the Custom Code tab and add JavaScript to handle URL hash changes.
  • Paste the following JavaScript inside the Head tag of your page. This script checks for the hash in the URL and opens the corresponding pop-up.

<script>
// This script opens pop-ups based on URL hash
document.addEventListener('DOMContentLoaded', function() {
  function openPopupFromHash() {
    var hash = window.location.hash.substring(1); // Remove the '#' from the hash
    var popup = document.getElementById(hash);
    if (popup) {
      // Assuming there is a method to open pop-ups, like a specific class
      // Add your code here to trigger the pop-up, e.g., popup.classList.add('open');
    }
  }
  window.addEventListener('hashchange', openPopupFromHash);
  openPopupFromHash(); // Open pop-up on initial load if hash is present
});
</script>

3. Create Shareable Links

  • Use the unique IDs to create direct links. For example, if your pop-up ID is popup1, then the URL will be yourwebsite.com#popup1.
  • Update your site's internal or external links to use these URL hashes.

4. Validate and Test

  • Publish your site, then test the links by pasting them into your browser to ensure they open the correct pop-up.
  • Ensure compatibility by checking on different devices and browsers.

Summary

To create shareable links for pop-ups in Webflow, assign a unique ID to each pop-up, add custom JavaScript in your project settings to open pop-ups based on URL hashes, and create direct links using these hashes. This allows users to access pop-ups directly via the URL.

Rate this answer

Other Webflow Questions