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:
<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>
popup1, then the URL will be yourwebsite.com#popup1.
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.